ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
VB Question (Bots)
VB Question // BotslanezeriNov 17, 2001, 9:31pm
This is what I'm doing:
Just added network capabilities to my Bank Bot and I have a class file that logs the Index of the SDK used and the World logged into, but I can't log two bots into the same world without getting an error from the class file What I need: To know if there is a way around it. -- Thanks, Ricky Lipe Degtur Solutions at http://www.degtur.com Stuff-X at http://www.stuff-x.com grimbleNov 18, 2001, 11:32am
First make sure you don't issue the aw_init for the second SDK instance when
you load it - once per app only. Beyond that, in the absence anything except the totally pointless "getting an error from the class file" you're on you're own pal. Grims. [View Quote] lanezeriNov 18, 2001, 1:16pm
I know how to log in the second bot, I just need to know how to let the damn
class file allow me to add the same world name without flipping out.. -- Thanks, Ricky Lipe Degtur Solutions at http://www.degtur.com Stuff-X at http://www.stuff-x.com [View Quote] kahNov 18, 2001, 5:46pm
class file as in .cls? if that's what you mean you'll have to tell us what
it does, or we can't help ya... KAH [View Quote] lanezeriNov 18, 2001, 7:18pm
You can't put the same thing in a class file twice. Which is what I said in
the first place. There has to be a way to put the same world name in a class file twice. -- Thanks, Ricky Lipe Degtur Solutions at http://www.degtur.com Stuff-X at http://www.stuff-x.com [View Quote] baronNov 18, 2001, 7:51pm
What everyone says is that you don't give sufficient information to get any help. It's like saying "I put some liquid in my gas tank and now my car won't run". We have no clue what "fuel" you use, posting/uploading the cls is the only way around it. In general you can try adding a new instance of the class.
-Baron [View Quote] lanezeriNov 18, 2001, 9:26pm
I don't know what else to tell you, there isn't much this could mean, if you
create a class file, then try to add the same thing to it twice you get an error. Was it really that hard to comprehend? -- Thanks, Ricky Lipe Degtur Solutions at http://www.degtur.com Stuff-X at http://www.stuff-x.com [View Quote] awst gavrocheNov 19, 2001, 8:17am
Well, actually yes.
You dont even give us the error. How can you expect help? And what the heck is the "same thing" supposed to mean. It could be anything. -Gav [View Quote] grimbleNov 19, 2001, 4:33pm
OK Ricky, lets have a guess at what you're doing here in the absence of any
additional information. I'll try to keep it in english. To me, it sounds like your trying to use a .cls like you would a .bas, when they are completely different concepts. The assumption from any VB programmer here is going to be that you understand how to use classes is you're going to include them in your project. Classes instantiate as COM objects, just like every object in VB (including forms) and, at a high level, the concept of an object is that you code a class - the definition of the object - once and instantiate it a number of times ... it becomes synonymous with a variable type such like longs, strings, etc. You can look at it as if it was a user defined data structure with a set of functions to "do stuff" with the data, but you can have many copies of the structure with different data in it and one set of code ... without the need for a load of messy array handling and needless parameter passing. If you want to use objects, then you create classes that represent single instances of "things", for example ONE BOT. Its a template for that "thing" just like in real life ... you would only design a cup once, and then create man of them from the design. So, you write a class as if its a single bot and then create two of them as different variables: So imagine a class file called "clsMyBot" with four member functions (I'm not looking at issues returning error codes here) ... Create, Login, Enter and MoveTo. This would be used something like this - I am typing this straight into Outlook Express and so I can't guarantee the syntax. Dim botExample1 as clsMyBot Dim botExample2 as clsMyBot Set botExample1 = new clsMyBot Set botExample2 = new clsMyBot awSDK.AwInit(AW_BUILD) botExample1.Create(...<Bot 1's universe details> ...) botExample1.Login(... <Bot 1's login parms> ...) botExample1.EnterWorld("AW") botExample1.MoveTo(... <Bot 1's position> ...) botExample2.Create(...<Bot 2's universe details> ...) botExample2.Login(... <Bot 2's login parms> ...) botExample2.EnterWorld("AWTeen") botExample2.MoveTo(... <Bot 2's position> ...) etc. etc. etc. This will give you two bots with identical behaviour - as defined in the class clsMyBot. If you want the bots are different, then that is a different template (different cup - different design), so you would need to create "clsMyOtherBot", copying the common code (creating/destroying the instance, logging in, entering the world, etc.) to the new bot or using a .bas file as a function library and passing the necessary parameters. Then you would have something like Dim botExample1 as clsMyBot Dim botExample2 as clsMyOtherBot Set botExample1 = new clsMyBot Set botExample2 = new clsMyOtherBot If you want to get as close to real object programming as VB lets you, then look into the Implements command, but I would stick to duplicating the common code for now. If this doesn't make any sense to you, then I'm afraid you're not ready for classes in your bots. You need to look at programming completely differently to use them effectively (which is the only way to use them to justify the additional cost in processing - and it is a significant cost) and I would think bots are not a good place to start. This is not procedural programming like using .bas files ... its a totally different programming model. Microsoft have examples - one of which is a coffee maker I think so search the help files for "coffee" maybe - to help you to think in the way you need to (unfortunately they're only up to the usual standard of M$ examples), but there are plenty of other resources on the web. If I can find some in the next few minutes, I'll post them here. Good luck, Grims. [View Quote] grimbleNov 19, 2001, 5:05pm
A couple of web resources you may find useful (get your reading goggles on!)
http://www.vbinformation.com/tut-obj.htm http://www.vbexplorer.com/ooptutor.asp http://www.vbexplorer.com/oop2.asp http://www.vbsquare.com/activex/begobjects/ http://www.vbsquare.com/activex/begobjects2/ http://www.vbsquare.com/activex/begobjects3/ and of course, the good old MSDN ... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/htm l/vbconprogrammingwithobjects.asp HTH, Grims. baronNov 19, 2001, 9:18pm
lanezeriNov 24, 2001, 2:56pm
I'm not trying to use a class file like a module. I'm using one class to
hold citizen information (Name, Session, X, Y, Z), and the other to hold Index numbers, and the world logged into for that sdk Index number. I understand what you're saying though, for each bot I log in, I need a different class name. But I'm not sure how many bots I will have logged in, (may be a dumb question) can I make variables have indexes? -- Thanks, Ricky Lipe Degtur Solutions at http://www.degtur.com Stuff-X at http://www.stuff-x.com [View Quote] |