Magsbot Class, Session 3
Saturday March 22, 2003 3pm VRT
note: added remarks or paraphrases are in [brackets], and the order of some chat has been changed for clarity. also a lot of spam has been removed...

This was a small class, only one serious student showed up (and one pest :P) so the class was shortened. If necessary, extra sessions will be added later to make sure everything is covered...

DLP Anne: morning everyone :)
Magine: so, any questions from last time, anne? :)
DLP Anne: nope
DLP Anne: lol
Magine: well, i decided to switch the order of classes around,
DLP Anne: ok
Magine: so today i'm going to talk about the behavior table
DLP Anne: coool
Magine: i thought i could give more practical examples that way
Magine: anyway....the behavior table is the closest thing magsbot has to a script
Magine: it's what controls all the bot's responses to events like hearing chat, seeing an avatar arrive or depart, clicks on objects...anything a bot can detect
DLP Anne: this is what you used to make my CA?
Magine: yes
DLP Anne: goood then i want to learn it becuase i want to replace cain with the full version
Magine: you open the behavior table window with alt-B , or using the Behavior... menu
DLP Anne: *open*
Magine: you can see there are 3 columns
Magine: the first, labelled "Active" just turns a particular row on or off
DLP Anne: kk
DLP Anne: i may have to stop [for some RL business]
Magine: (to DLP Anne) ok, let me know when and i can pause, since you are the only student today :D
DLP Anne: ok
Magine: the second column in the table is "Event" and that column is used to define the event that will trigger the action in the third column
Magine: the first column can be toggled on/off by double clicking it
DLP Anne: brb
Magine: (to DLP Anne) ok
Magine: and the other two columns, Event and Action, can be edited by double clicking....when you double click them, the edit box opens
Magine: (pausing for anne to get back)
DLP Anne: back
DLP Anne: sorry
Magine: np
Magine: so...the basic idea of the table is very simple, even if the stuff in the rows looks obscure :D
Magine: when an event occurs, it is processed in the table,
Magine: and rows that match the event that occurred,
Magine: are triggered
Magine: now as you can see, most of the events have some code other than the event name
DLP Anne: yes i see
Magine: that code is a conditional expression that specifies an additional condition that must be met, for the action to be triggered.
DLP Anne: so what is in events has to be said or done before the action can be triggered
DLP Anne: ?
Magine: so, if a row has an event that is just "HEAR", then the action on that same row would be triggered any time the bot hears someone
DLP Anne: ok got ya
Magine: but if a row has the event "HEAR" and also some expression like for instance, @eq[$avname,Magine]
Magine: then that expression has to equate to true for the action to be triggered
Magine: as you recall from last week, an expression that = 0 is "false" and anything else is "true"
DLP Anne: ok
DLP Anne: right
Magine: some of the events you can see in the table are "undefined" so nothing happens on those rows
Magine: and the REM action is just a "remark", in other words it does nothing
DLP Anne: yes i remember that part
Magine: let's insert a row at the top of the table to play with
Magine: you can see there is a highlight (more like an outline) that shows the selected row
DLP Anne: yes
Magine: move that highlight to the top by clicking near the top or using arrow keys, then press Alt-I to insert a row there
DLP Anne: ok got it
Magine: then double-click on the Event column to get the edit box
DLP Anne: got it
Magine: in the edit box, you can just type whatever you want to go there, but you can also use the various insert buttons at the bottom to [insert text and] help you remember all the possible things you might want to put there :)
DLP Anne: I put hear in there lol
Magine: so trying clicking "insert condition" and take a look at the list
Magine: (well delete the "UNDEFINED" in [the event column] first)
DLP Anne: i have it already inserted
Magine: click on "chat message contains a particular word" in the insert condition box there, and you will see it inserts some code for you, @word[$wordtolookfor].
DLP Anne: I did
Magine: ok, so just replace "$wordtolookfor" with your own word
Magine: like @word["foobar"]
DLP Anne: ok done
Magine: you can expand the condition by using "and" and "or" symbols, && and ||
Magine: (you can just click the AND or OR buttons if you forget the symbol)
Magine: that latter is two pipe symbols |
DLP Anne: k
DLP Anne: you mean cap i's
Magine: nope, the pipe symbol, vertical line
Magine: it's on the same key as \, but shifted
DLP Anne: i see it
Magine: oh, i just realized we didn't choose an event
Magine: so in the edit box, move the cursor to the [beginning of the line] and then click the "insert event" button
Magine: and choose HEAR in this case
DLP Anne: ok i have my event
DLP Anne: yup done
Magine: of course you could just type HEAR etc,
Magine: the insert buttons are just a convenience, and to help you remember all the possibilities...
Magine: i need them myself :D
DLP Anne: lol i know I will
Magine: anyway, after you have HEAR @word["foobar"] then click Ok
DLP Anne: foobar has to be in " " ?
Magine: you can omit the quotes in most cases if the word is all letters
DLP Anne: ok
Magine: but if it's a phrase with a space, or special characters [other than the underscore _ ], then you'd need quotes [also if the first character is a number]
DLP Anne: ok
Magine: and the quotes don't hurt anything anyway :)
DLP Anne: so  for pactical putposes and  (to not forget) its good to get used to using the quotes?
Magine: it can't hurt anne :)
DLP Anne: kk
Magine: ok, now let's add an action....double click the action column
Magine: for our first simple example here, we can have the bot say something in response
Magine: so just type
Magine: SAY "something you want the bot to say"
Magine: and click ok
Magine: now, be sure to toggle the Active column or your new row will be ignored
Magine: once the active column says On, we can test
DLP Anne: im annoyed
[Eve]: Watching an avatar run around while you're trying to learn is annoying
DLP Anne: hahaha yessssssssssssssss
Magine: mags what do you think of foobar?
[Mags]: foobar to you too!
DLP Anne: Mags is annoyed
[Eve]: Watching an avatar run around while you're trying to learn is annoying.
Magine: so anne, did [eve] say what you wanted her to? :)
DLP Anne: yes
DLP Anne: watch
DLP Anne: Magine is annoyed
[Eve]: Watching an avatar run around while you're trying to learn is annoying.
Magine: heheh
DLP Anne: see lol
Magine: are you annoyed, eve?
[Eve]: Watching an avatar run around while you're trying to learn is annoying.
Magine: i guess she is :D
DLP Anne: hahaha
DLP Anne: ok she is off
Magine: anyway, that's the basic idea, everything else is an extension of the same concept
DLP Anne: ok
DLP Anne: will just take some practice is all
Magine: yep :)
Magine: now, there are a lot more complex conditions you can set, of course
DLP Anne: I hate to cut this short but i have about 5 minutes and I have to leave :(
Magine: (to DLP Anne) ok, well, i guess we can start from here next time
DLP Anne: that would be great im so sorry :(
DLP Anne: lol
Magine: i'll just quickly mention some special things you can do with the behavior table processing
DLP Anne: ok
Magine: uh, well i should have started on functions, but for this quick 5 minute thing i guess you understand basically what a function is?
DLP Anne: i think so  magine
Magine: ok, i'll go into more detail on that next time
DLP Anne: ok
Magine: but i wanted to mention a function you can use to tell if a previous row of the behavior table has triggered an action
Magine: that is the @reacted function
DLP Anne: k
Magine: you would use that in the event column to check if any previous row of the same event type has been triggered
Magine: so if you had for instance a number of rows with HEAR events,
Magine: and you wanted a default response in case the bot hears something but none of the other conditions in the previous rows were met
Magine: (like if you had a number of rows with HEAR @word[someword])
Magine: then in the last row you could use HEAR @reacted=0 as the event
DLP Anne: ahh ok
Magine: and some default response in that row's action column
DLP Anne: that would be under all the other HEAR rows?
Magine: right
DLP Anne: or after all of them    ahh ok
DLP Anne: so the bot goes down the list till it finds the right one
Magine: correct
DLP Anne: ok gotcha :)
Magine: i guess i should also explain how events are checked in the table, but i guess that will have to wait [til next time]