Guest
Feb 5, 2012, 8:57 pm UTCHome arrow Reference Tables arrow Function Variables
header image
Function Variables
Written by Dream Dancer   
Jan 19, 2008 at 10:31 AM

Function Variables are variables that act like functions, they preform simple things like adding and subtracting other variables, or getting chunks of the message out as single words. They are a means to preform functions which would otherwise require you to step into WolfScript for the results, making them handy for quick botscript actions, say like ensuring that the third word of a command is someone who exists in a database so you don't grant something to someone who isn't a member, or to prevent an error from popping up and corrupting everything. The table below is not alphabetical and organized in the order in which the rather massive IF ELSEIF construct is used to parse the variables in the FixText function.

Do remember that like all variables, you need to use the [Square Brackets] around the item otherwise the parser does not see the function and nothing happens.

gapperFirst chunk is message parsing functions.

gapperNow we deal with the $LOG and the sole $DATABASE functions.

Break out the table to explain $LOG structure here somewhat. Log files are plain text files, overall, the system does not care nor regard the extension of the file, you can give it whatever type of extension you want. What does matter is the internal structure of the file, everything is "quote delimited", and there's only one element per line, each line standard CR+LF terminators. The first entry is the number of records in the file, followed by the records, where first you will have the name of the record, followed by a line containing the number of entries of that record, with the entries after that.

RECORDS
RECORD ONE
ENTRY COUNT
ENTRY ONE
ENTRY TWO
RECORD TWO
ENTRY COUNT
ENTRY ONE
ENTRY TWO
A random log does away with the first two lines of this structure, leaving you with just the ENTRY COUNT and the entries themselves. So you can build the actual initial random log system yourself, using the bot to create the entries for the file, however, once you adjust it to work as a random log, it will become corrupted if you use a $LOG function to attempt to extend it. The only means to extend it after that is to manually add lines to the file, (with quotes), and update the count in the first line.

gapper[DB:FIELD:DBID:TABLE:RECORDID]
$DATABASE: Set variable {#0} to be value of field {#1} in database {#2} in table {#3} from record {#4}

This deserves some special attention, I put the two items right next to each other so you can see that there is two means of achieving the same thing, one with the variable function, the other with normal botscript. There's no real difference between the two commands, so the variable function is something of a holdover from earlier bots. In the function, FIELD=#1, DBID=#2, TABLE=#3, and RECORDID=#4, the usage would be something like "Store {[DB:FIELD:DBID:TABLE:RECORDID]} to variable {[VARIABLE]}", I'm sure there's other reasons to use the curious thing in other ways, I just don't see any. Goofy

gapperMathematical elements, any operands can be either fixed numbers or variables. Any failures by the functions to execute as expected returns an empty result. Also, the engine will display the error message in the receive window as well.

 

Last Updated ( Aug 01, 2009 at 06:42 AM )
Next>
header image