Function names shown in green are actually macros. See User-Defined Functions.
@newinstance[$name,@citizenid,$privpassword,@port,$address,@entermode,@appear]Creates a new bot instance and returns the handle of that instance. (Note that you can create instances that will run in different universes or even run by different owners!)
New with version 3.0: The last two arguments (shown in gray) are optional. If they are left out, then the default settings from the Options/Connection menu are used. You can use @entermode without using @appear, if you choose.
If used, @entermode specifies if the instance should immediately enter the world and if it should run in global mode. If @entermode is 0, the instance will not enter the world; if @entermode is 1, then the instance will enter the world in non-global mode; if @entermode is 2, then the instance will enter the world in global mode. If @entermode is any other number or not specified, then the settings from the Options/Connect menu will be used. Note that if @entermode is 0 then after creating the instance, you will have to use a command like ENTERWORLD, ENTERGLOBAL or TELEPORT to make the instance enter a world.
The @appear argument specifies if the instance should immediately appear in that world by going to specific coordinates. If @appear is 0 (false) then the bot will enter the world, but not appear at any specific location. (If @entermode is 0, then @appear is ignored.)
The world and coordinates used will be the same as the world and coordinates of the instance that calls the @newinstance function. If no instances are running, then the world and coordinates will be taken from the Location tab instead. If @appear is 0 then after the instance enters a world, you will have to use APPEAR, TELEPORT or MOVETO to make it appear at a location there.
Also note that the newly created instance will not automatically become the active instance (i.e. the instance controlled by the Chat, Location and Action panels) unless there is no other instance running. If you want it to be the active instance, use the SETACTIVE command after creating it.
@newadmininstance[$address,@port,$password]
Creates a new administative instance and returns the handle to that instance. Admin instances do not connect to the world server in the same way that a regular bot does; instead they are used to remotely control the world server itself. See the SDK help for an overview. The $address and @port arguments do not refer to the address and port of the world server, they refer to the IP address and port of the computer that the world server is running on. Likewise the $password argument does not refer to a privilege password, they refer to the password to the world server. Admin instances can't use most of the usual bot commands, but can instead use special admin commands that other bots can't.
@instance
Returns the handle to the current instance. In the context of the Behavior Table, the current instance is the instance receiving the Event message. In the context of an Action Button or immediate mode command (Actions/Do menu item), the current instance will be the "Active Instance", that is, the instance whose information is being displayed on the control panels (Chat and Location tabs).@instance_
The same as @instance except that it gets the value from the event queue instead of immediately from the SDK. Since the current instance can change within an action, you would normally use @instance to get the correct value. However in the TERMINATEINSTANCE event, the actual bot instance probably won't exist by the time the event is processed in the behavior table, so you would use @instance_ instead, to get the handle of the instance that just ended.@activeinst
Returns the handle to the "Active Instance", that is, the instance whose information is being displayed on the control panels (Chat, Location and Actions tabs).@instances
Returns a count of existing instances.@insthandle[@index]
Returns the instance handle from its current index (position in the Instance List). Note that the index may change as instances are added or deleted, but the handle will remain constant for the life of the particular instance.@instindex[@handle]
Returns the instance's current index from its handle. (See note above.)@instexists[@handle]
Returns true if the specified instance exists.@instid[@handle]
Returns a unique ID number for the instance, that does not change even if the instance is disconnected and reconnects with a different instance number (handle). (The ID is actually the date+time that the instance was first created.) (Version 4.3.26.)@connected
Returns true (1) if any bot instances are connected.@connectstate[@instance]
Returns a number indicating the connect state of the specified instance.-1= (invalid instance)@inworld[@handle]
0= waiting for login (dark yellow)
1= waiting to enter (yellow)
2= connected (green)
3= disconnected (red)
4= failed (gray)(Colors refer to the color of the LED next to the instance on the Instance List window.)
Returns true if the specified instance has entered a world.@visible[@handle]
Returns true if the specified instance has appeared at a specific location within a world.$ipof[@session]
Returns an IP address in the format "0.0.0.0" for a particular session. You can use this with EJECTADD, EJECTDELETE, etc. to modify a world's ejection list. Note: prior to version 1.8.9 this was named $ip.$ip[@ip]
Translates an IP number to an IP address (like "0.0.0.0"). NOTE: this formerly returned an IP address from a session number. It was changed as of version 1.8.9. You should now use the $ipof function if you want to find an IP address from a session.@ip[$ip]
Translates an IP address (like "0.0.0.0") to an IP number.@port
Returns the port that the instance is connected to.$addr
Returns the address (e.g. "www.activeworlds.com") that the instance is connected to. Note: a few releases prior to 1.8.9 had a macro named $addr that translated an IP number to an IP address. That function is now named $IP instead.$instnote[@instance]
Returns the instance list note of the specified instance.
(The two Citizen functions below have been removed. Use the newer CITIZENINFO and CITIZENINFO_ Actions instead.)@citizen[$name]
Returns the citizen number of the citizen specified by name.$citizen[@n]
Returns the citizen name of the citizen specified by number.
@ispresent[$name]
Returns true (1) if an avatar with the specified name is near the current instance. If multiple avs of the same name are present, returns the number.@ispresent_[@session]
Returns true (1) if an avatar with the specified session is near the current instance.@avspresent
Count of the number of avatars near the current instance.
@selected[$name]
Returns true if the specified nearby avatar has been selected on the NearBy List (see SELECT, DESELECT actions).@selected_[@session]
Returns true if the specified nearby avatar has been selected on the NearBy List (see SELECT_, DESELECT_ actions).@tagged[$name]
Returns true if the specified nearby avatar has been tagged on the NearBy List (see TAG, UNTAG actions).@tagged_[@session]
Returns true if the specified nearby avatar has been tagged on the NearBy List (see TAG, UNTAG actions).$nearnext
Returns the next name in the Nearby List (see RESETNEARBY action). (Formerly this function was called "$listnext", but I changed it to avoid confusing it with functions that deal with variable lists. For backward compatibility, there's a $listnext macro defined in the userdefs.udf.)@nearnext
Returns the next session in the Nearby List (see RESETNEARBY action). (Formerly this function was called "@listnext", but I changed it to avoid confusing it with functions that deal with variable lists. For backward compatibility, there's a @listnext macro defined in the userdefs.udf.)$taggednext
Returns next tagged name in nearby list (see RESETNEARBY action)$selnext
Returns next selected name in nearby list (see RESETNEARBY action)@sessionof[$name,@lastfound]
Returns the session number of avatar $name, provided that avatar name exists in the Nearby List. The optional @lastfound argument specifies where on the list to start looking, so if there are multiple avatars with the same name, you can call @sessionof repeatedly to determine all their names.$nameof[@session]
Returns the name of the avatar with session number @session, provided that avatar exists in the Nearby List.
$avname_[@session]
This is similar to the $nameof function, except that it searches the avtracking list and the instance list instead of the nearby list; therefore it will find the avatar name of the specified session if that session is visible to any bot instance, not just the current one; or if the session is one of the instances running in that copy of Magsbot. Don't confuse this with the $avname macro!
@avsession_[$name]
This is similar to the @sessionof function, except that it searches the avtracking list and the instance list instead of the nearby list; therefore it will find the session name of the specified avatar name if that name is visible to any bot instance, not just the current one; or if the name is one of the instances running in that copy of Magsbot. Don't confuse this with the @avsession macro!
@citnumof[@session]
@privilegeof[@session]
Returns the citizen number of the avatar with session number @session, provided that avatar exists in the Nearby List.
Returns the privilege ID of the avatar with session number @session, provided that avatar exists in the Nearby List.
@facezx[@ns,@we]
Returns the yaw for the bot to face (FACE command) in order to face toward the specified coodinates..@faceav[@avsession]
Returns the yaw for the bot to face (FACE command) in order to face toward the specified avatar.@avfaceav[@avsession1,@avsession2]
Returns the yaw for the @avsession2 to face (FACE command) in order to face toward @avsession1.@safezx[$safelist,@ns,@we]
Returns true if coords are within safe area indictated by the specified safe list. (See here for information about creating a safe list.)@safe_[$safelist,@avsession]
Returns true if the specified avatar is within safe area indictated by the specified safe list. (See here for information about creating the safe list.) Note: you can derive an avatar's session from its name using the @sessionof function.@safe[@avsession]
Returns true if the specified avatar is within safe area indictated by the list named "Safe". (This is the same as @safe_ except that the list name must actually be "safe" in this case, whereas you can specify any list name using @safe_. See here for information about creating the safe list.) Note: you can derive an avatar's session from its name using the @sessionof function.@dist2[@ns1,@we1,@ns2,@we2]
Distance between coordinates in 2 dimensions (i.e., not considering altitude).@dist3[@ns1,@we1,@alt1,@ns2,@we2,@alt2]
Distance between coordinates in 3 dimensions (i.e., also considering altitude).@avdist2[@avsession1,@avsession2]
Distance between two avatars in 2 dimensions (i.e., not considering altitude). Note: you can derive an avatar's session from its name using the @sessionof function.@avdist3[@avsession1,@avsession2]
Distance between two avatars in 3 dimensions (i.e., also considering altitude). Note: you can derive an avatar's session from its name using the @sessionof function.@botdist2[@avsession]
Distance between the bot and an avatar in 2 dimensions (i.e., not considering altitude). Note: you can derive an avatar's session from its name using the @sessionof function.@botdist3[@avsession]
Distance between the bot and an avatar in 3 dimensions (i.e., also considering altitude). Note: you can derive an avatar's session from its name using the @sessionof function.@nearzxy[@ns1,@we1,@alt1,@ns2,@we2,@alt2,@near_distance]
Returns true if a specified location is "near" another location. "Near" is defined by the final argument, in SDK units (i.e. 1000=1 AWB unit).@nearbot[@ns,@we,@alt,@near_distance]
Returns true if a specified location is "near" the bot. "Near" is defined by the final argument, in SDK units (i.e. 1000=1 AWB unit).@near[@ns,@we,@alt,@near_distance]
Exactly the same as @nearbot, above. Maintained for backward compatibility only.@nearav[@avsession,@ns,@we,@alt,@near_distance]
Returns true if a specified location is "near" the specified avatar. "Near" is defined by the final argument, in SDK units (i.e. 1000=1 AWB unit). Note: you can derive an avatar's session from its name using the @sessionof function.@botnearav[@avsession,@near_distance]
Returns true if the specified avatar is "near" the bot. "Near" is defined by the final argument, in SDK units (i.e. 1000=1 AWB unit). Note: you can derive an avatar's session from its name using the @sessionof function.@avnearav[@avsession1,@avsession2,@near_distance]
Returns true if the first specified avatar is "near" the second specified avatar. "Near" is defined by the final argument, in SDK units (i.e. 1000=1 AWB unit). Note: you can derive an avatar's session from its name using the @sessionof function.
@surveying[@instance]
Returns true (1) if the specified instance is performing a survey.@cellnext
(NOTE: a much simpler way to do the following is to use the SURVEYWORLD Action.)
The @cellnext function starts a survey of the entire world. Before calling this, do SETVAL_ CELL_ITERATOR=0. Then continue to call @cellnext as long as the result is 0, to complete the survey. You can check the result of @cellnext in two different ways. The default, asynchronous method is to check the value of @sdkerrorwithin a CELLRESULT event. If you prefer to use a synchronous method, you can instead examine the value returned by @cellnext itself; but if you use that method, then you should also disable the CELLRESULT callback by adding this to your magsbot.ini file:[Handlers]
cellresult=0
@querying[@instance]Note: the reason for separate commands/functions for heights and textures is that heights are short integer (16 bit) values and textures are unsigned character (8 bit) values.
Returns true (1) if the specified instance is performing a terrain query.
@aheight[@p,@i]New in version 4.1 b26:
Returns a value from the array of height values during a TERRAINDATA event. The @p argument is a pointer to the terrain data and @i is the index of the item to return. The pointer is obtained from the @atr[TERRAIN_NODE_HEIGHTS] attribute. Use the @atr[TERRAIN_NODE_HEIGHT_COUNT] attribute to determine the number of values, and @atr[TERRAIN_NODE_Z] and @atr[TERRAIN_NODE_X] to determine the location of the node on the page being queried. See the SDK documentation for information about the format of terrain data that is received during a TERRAINDATA event. (Formerly this function was named @height, but I changed it in version 5.2.9 to avoid conflict with the more frequently-used @height macro (see below). Hopefully this won't cause any big problems for anyone.)Example: during a TERRAINDATA event:
@p=@atr[AW_TERRAIN_NODE_HEIGHTS];@atexture[@p,@i]
@n1=@heights[@p,1]; < the first height value
@n2=@heights[@p,2]; < the second height value
etc.
Returns a value from the array of texture values during a TERRAINDATA event. The @p argument is a pointer to the terrain data and @i is the index of the item to return. The pointer is obtained from the @atr[TERRAIN_NODE_TEXTURES] attribute. Use the @atr[TERRAIN_NODE_TEXTURE_COUNT] attribute to determine the number of values, and @atr[TERRAIN_NODE_Z] and @atr[TERRAIN_NODE_X] to determine the location of the node on the page being queried. See the SDK documentation for information about the format of terrain data that is received during a TERRAINDATA event. (Formerly this function was named @texture, but I changed it in version 5.2.9 to avoid conflict with the more frequently-used @texture macro (see below). Hopefully this won't cause any big problems for anyone.)Example: during a TERRAINDATA event:
@p=@atr[AW_TERRAIN_NODE_TEXTURES];@hbuffer[@instance]
@n1=@texture[@p,1]; < the first texture value
@n2=@texture[@p,2]; < the second texture value
etc.
Returns a pointer to the height buffer. See @height_ below.@tbuffer[@instance]
Returns a pointer to the texture buffer. See @texture_ below@height_[@buffer,@cell_z,@cell_x]
formerly: @height_[@instance,@cell_z,@cell_x]
Returns height data from the terrain data buffer. Each bot instance potentially has its own terrain page buffer for terrain queries, which is created when a query is made (QUERYTERRAIN), or when a buffer is loaded from a file (LOADTERRAINPAGE), and is retained until a new query is made, the instance is terminated, or the buffer is flushed (FLUSHBUFFER). The @height_ function (and @texture_ function below) can be used to examine the contents of the buffer. The pointer to the buffer for a particular bot instance is obtained using the functions @hbuffer (for heights) or @tbuffer (for textures).Unlike @height (and @texture) which return values from the data array for a single node as the data is received during a TERRAINDATA event, the @height_ and @texture_ functions can return the data for a cell at the specified coordinates anywhere within the terrain page. Note however that the specified coordinates are relative to the terrain page in the buffer, not absolute coordinates within the world where the query was made.
In other words, if the last query was at @page_z, @page_x, then @height[@z,@x] would return the height of the cell at AW coordinates NS=@page_z*128+@z, WE=@page_x*128+@x. (128 = the width of a terrain page.)
Also remember that SDK coordinates for specifying avatar or object location are 1000x cell coordinates, so for example a cell at -1,1 (1S 1W) is at -1000,1000 in terms of bot location.
Example: after a terrain query has completed:
@n1=@height_[@buffer,0,0]; < the height at cell 0,0 (0n 0w or NS=0 WE=0)@texture_[@buffer,@cell_z,@cell_x]
@n2=@height_[@buffer,0,-1]; < the height at cell 0,-1 (0n 1e or NS=0 WE=-1000)
@n2=@height_[@buffer,1,0]; < the height at cell 1,0 (1n 0w or NS=1000 WE=0)
@n2=@height_[@buffer,-1,1]; < the height at cell -1,1 (1s 1w or NS=-1000 WE=1000)
etc.
formerly: @texture_[@instance,@cell_z,@cell_x]
See the explanation for @height_, above.@height[@z,@x,@v]
Previously a macro of the [Height] button, this is now (version 6.5.7) a built-in function. It returns the height of terrain at any point, where @z and @x are the SDK coordinates. To use the height function, you must first load terrain info for the world by clicking the "load terrain buffers" button on the Terrain tab of the actions panel.
The optional @v argument was added in version 7.3.14. It is a vlist that the function will use to return some cell data. If you use the optional @v argument, you need to create the vlist yourself first (@v=@vlist). In previous versions the cell data was returned in the local variable list, but that was a bad idea since you might already be using variables with those same names, that @height would overwrite. The usefulness of the data is rather obscure anyway; mostly it was for my debugging purposes when I was testing the @height function. The data is:
@pz, @px = the terrain page coords (e.g. 0,0 is the terrain page at the center of the world)
@cz, @cx = the cell coords within the terrain page
@dz, @dx = the coords within the cell
@cellz, @cellx = the absolute cell coords within the world
@texture[@z,@x,@v]
The optional @v argument was added in version 7.3.14. It is a vlist that the function will use to return some cell data. If you use the optional @v argument, you need to create the vlist yourself first (@v=@vlist). In previous versions the cell data was returned in the local variable list, but that was a bad idea since you might already be using variables with those same names, that @texture overwrite. The usefulness of the data is rather obscure anyway; mostly it was for my debugging purposes when I was testing the @texture function. The data is:
Previously a macro of the [Texture] button, this is now (version 6.5.7) a built-in function. It returns the texture of terrain at any point, where @z and @x are the SDK coordinates. To use the texture function, you must first load terrain info for the world by clicking the "load terrain buffers" button on the Terrain tab of the actions panel.
<>@pz, @px = the terrain page coords (e.g. 0,0 is the terrain page at the center of the world)
<>@cz, @cx = the cell coords within the terrain page
<>@dz, @dx = the coords within the cell
<>@cellz, @cellx = the absolute cell coords within the world
@copyhbuffer[@hbuffer]
Creates a copy of the specified heights buffer. Use FREEHBUFFER to free the buffer when you're done with it. The buffer can be viewed using the SHOWTERRAINBUFFER command (version 5.3).@copytbuffer[@tbuffer]
Creates a copy of the specified textures buffer. Use FREETBUFFER to free the buffer when you're done with it. (Note: due to a bug this was not actually available until version 5.2.4.) The buffer can be viewed using the SHOWTERRAINBUFFER command (version 5.3).
New in version 7.4.7:
@createhbuffer
Creates an empty heights buffer. Use FREEHBUFFER to free the buffer when you're done with it. The buffer can be viewed using the SHOWTERRAINBUFFER command. (Version 7.4.7).@createtbuffer
Creates an empty textures buffer. Use FREETBUFFER to free the buffer when you're done with it. The buffer can be viewed using the SHOWTERRAINBUFFER command. (Version 7.4.7).
@atr[$attrib_name]
Returns a numeric AW_ATTRIBUTE specified by name. For example:. @atr[SESSION]*@atr_[n]
Returns a numeric AW_ATTRIBUTE specified by number. For example:. @atr[12]$atr[$attrib_name]
Returns a string AW_ATTRIBUTE specified by name. For example:. $atr[WORLD_NAME]*$atr_[n]
Returns a string AW_ATTRIBUTE specified by number. For example:. $atr[12]@atri[$attrib_name]
Returns a numeric AW_ATTRIBUTE specified by name. For example:. @atr[SESSION]*$atri[$attrib_name]
Returns a string AW_ATTRIBUTE specified by name. For example:. $atr[WORLD_NAME]*@atnum[$attrib]
Returns an AW_ATTRIBUTE number, specified by name.
For example:. @atnum[WORLD_NAME]$atname[@num]
Returns an AW_ATTRIBUTE name, specified by number.
For example:. $atname[12]*Note that @atr and $atr return the value of an AW attribute at the moment that the Event occurred that triggered the Action that the @atr or $atr function is within. Naturally if you are responding to a HEAR event, for instance, you need to know the value of $atr[AVATAR_NAME] (the name of the speaker) at the time the chat was heard, not a few milliseconds later, because some other Event could have occurred since the first, and changed $atr[AVATAR_NAME]. However, in some cases you do need to know the immediate value of an AW attribute, and in cases such as these you would use @atri or $atri instead or @atr or $atr, to get the immediate AW attribute value.
$worldattrib[@n]
Returns a world attribute, by at dump number. (Not an AW attribute number.)
Derived from @atr or $atr:$avname
Avatar name, during events such as AVATARADD, HEARCHAT, etc. (Don't confuse with the $avname_ function!)$worldname
The current world name.Bot position, gesture, type and session number:
@sessionAvatar (not the bot) position, gesture, type and session number
Bot's session ID.@session_
Bot's session ID, but taken from the event queue rather than immediately from the SDK. Useful only in the TERMINATEINSTANCE event, where it is necessary because the actual bot instance will not exist by the time the event is processed in the behavior table; in that case you would use @session_ to get the session number of the instance that just ended.@ns
Bot NS position (same as @atr[MY_Z]).@we
Bot WE position (same as @atr[MY_X]).@alt
Bot altitude (same as @atr[MY_Y]).@yaw
Bot yaw (same as @atr[MY_YAW]).@gesture
Bot's current gesture (same as @atr[MY_GESTURE]).@type
Bot's avatar type (same as @atr[MY_TYPE]).
(Functions in purple are derived from nearby avatar tracking):@avsession@inbounds[@session,@vlist]
An avatars's ID, same as @atr[AVATAR_SESSION]. (Don't confuse with the @avsession_ function.)@avZ[@session]
An avatar's NS position.@avX[@session]
An avatar's WE position.@avY[@session]
Avatar altitude.@avYaw[@session]
Avatar's yaw.@avgesture[@session]
Avatar's gesture.@avtype[@session]
Avatar type during an event.@avpitch[@session]
Avatar pitch.@avzone[@session]
Avatar zone number. (Avatar tracking and zone checking must be turned on for the bot instance.)$avzone[@session]
Avatar zone name. (Avatar tracking and zone checking must be turned on for the bot instance.)@avstate[@session]
Avatar state (-1=error, 0=normal, 1=running, 2=flying, 3=swimming, 4=falling, 5=jumping, 6=warping). In Magsbot 7.0, additional states are 7=riding, 8=sliding1, 9=sliding2, 10=sliding3, 11=climbing.
Returns true if the specified session is within the bounds of a boundary list. A boundary list is a vlistcontaining the variables @N, @S, @W and @E, SDK-style coordinates defining a rectangular area. (The @inbounds function is a more efficient replacement of the @safe_ macro. You can use the SetBoundsN, SetBoundsS, SetBoundsW and SetBoundsE buttons in the root . tab of the Actions panel to conveniently define a boundary list.)@avtracking_
Returns the avatar tracking state for the current instance. See AVTRACKING, AVTRACKING_ commands.
@objnum
Object number, during Events like CELLOBJECT, etc. NOTE: remember like all values returned by @atr (or $atr) this reflects the value at the time of the event that triggered the Action that the expression containing the function is in. If you need to know the value at the moment that the expression is evaluated, then use @atri[OBJECT_NUMBER] instead.@said
@whispered
@broadcast
Use these macros with the HEAR event to determine what mode the speaker used. Each will return true (1) under the appropriate conditions.@isbot[$name]
Returns true (1) if $name has brackets around it, indicating a bot name.@botcmd
Returns true (1) if the incoming chat string is a bot command, i.e. if the first word of the chat string is the bot's name.
(See here for general information about zones.)
@zonechecking_(See also zone-related actions and events.)
Returns true (non-0) if zonechecking is on, false (0) if it's off, for the current instance.@getzone[$zone,$Nvar,$Svar,$Wvar,$Evar,$Bottomvar,$TopVar]
Retrieve the information for a particular zone and store it in variables with the specified names. It returns 0 if fails, 1 or 2 if successful; 1 if only N,S,W,E boundaries are set, or 2 if Top and Bottom boundaries are also set. For example: @x=@getzone[MyZone,North,South,West,East,Bottom,Top] would put the values into @North, @South, etc.@inzone[$zone,@session]
Returns true (non-0) if the specified session is within the named zone, false (0) if not.@locinzone[$zone,@z,@x,@y]
Returns true (non-0) if the specified coordinates are within the named zone, false (0) if not.$avzone[@session]
Find the name of the zone that an avatar is in (blank if not in any zone).@avzone[@session]
Find the number of the zone that an avatar is in (0 if not in any zone). While the zone number can change with the addition or deletion of zones, and there is no way provided to tell what number a particular zone is, this function is useful for comparing zones within a particular event. (Comparing by number is a little faster than comparing by name.) For example this function could be used in a chat-filtering bot, to tell if the speaker and surrounding avatars are within the same zone.@zonestate[$zone]
Returns true (non-0) if the zone is active, false (0) if it's not. If the zone is not active, then ZONEENTER and ZONEEXIT events will not be generated.
@zonepriority[$zone]
Returns the zone's priority. When zones overlap, the zone with the higher priority setting will determine which zone takes precedence. New in version 7.4.6.$zones
Get a comma-delimited list of existing zone names.$zonegroup[$zone]
Retrieve the group name of the zone.
Magsbot version 3.0 documentation
@objectadd[@ns,@we,@alt,@yaw,$model,$desc,$action,@tilt,@roll]
Creates an object and returns its object number. The @tilt and @roll arguments are optional and are new for version 3.0.@objectadd_[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action]
The same as @objectadd except the arguments are in a different order, and @tilt and @roll are not optional. New for version 3.0.@objectload[@owner,@timestamp,@ns,@we,@alt,@yaw,$model,$desc,$action,@tilt,@roll]
Like @objectadd except also allows you to specify the object's owner (citizen number) and timestamp. The timestamp is a @ctime value. The @tilt and @roll arguments are optional and are new for version 3.0.@objectload_[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action]
The same as @objectload except the arguments are in a different order, and @tilt and @roll are not optional. New for version 3.0.@objectchange[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,$model,$desc,$action,@tilt,@roll]
Changes an existing object and returns the new object number. Requires the current object number of the object (first argument), the current NS and WE coordinates (second and third arguments), and the object owner's citizen number (forth argument). The specified owner must be the same as the current object's owner, or someone with eminent domain in the world containing the object. The @tilt and @roll arguments are optional and are new for version 3.0.@objectchange_[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action]
The same as @objectchange except the arguments are in a different order, and @tilt and @roll are not optional. New for version 3.0.
History and overview of build functions
In Magsbot version 7.0, the @objectadd, -change and -load functions have been changed. The original functions (pre version 3) didn't have the tilt and roll arguments; when AW version 3 with 3-axis rotation arrived, I added new versions of each of the object functions, that would take the new tilt and roll arguments. The version 3 function names were the same but with an underscore added, i.e. @objectadd was the pre-version 3 function and @objectadd_ was the version 3 function.
In Version 7 of Magsbot, I wanted to simplify things by consolidating these two sets of functions into one. The underscore-name functions have been removed, and the original functions updated to support tilt and roll, as well as additional optional arguments necessary to manipulate special objects available in AW version 4. In the interest of backward compatibility however, the underscore-name functions still exist as macros in the userdefs.udf file. Also, if you have any scripts that use the very old original versions of the functions without tilt and roll, (and if you don't want to bother updating to the new usage) you can simply replace the old functions with the macros @objectadd_old, @objectload_old or @objectchange_old.
In AW version 4, several new kinds of objects have become available: Zone objects, Particle Emitters, Movers and Cameras. These objects have many properties associated with them that are not defined as AW attributes. Instead, the special objects' properties are stored in several kinds of data structure that an SDK programmer must use when creating these object types with a bot. To simplify things for Magsbot programming, the special object properties can be stored in a vlist, and the vlist passed to the object building functions. Or, a string of hexidecimal characters representing the data can be sent. (This string is the same format that appears for special objects in propdump files.) The hexidecimal string can be obtained either during a survey (CELLOBJECT event) from the $objdatastr function, or by converting a vlist to a string using the $objdatafromvlist function. The new @objectaddv, @objectloadv and @objectchangev macros are used when you want to pass a vlist; the actual functions @objectadd, @objectload and @objectchange take the object properties data in the form of a hexidecimal string or an object data block (see below). See here for more information and examples of creating the new objects.
In Magsbot 7.3, the optional final argument to the @objectadd etc. function can now be either an object hex string or an object data memory block. The memory block can be created using @copydata, @objdatafromvlist or @datafromstr. Also @objectaddp macros were added that take the object data memory block pointer only.
@objectadd[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,$datastr]
@objectadd[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
@objectaddv[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@vproperties]
@objectaddp[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
Creates an object at the specified location. The optional @objtype argument specifies an object type, if it is other than an ordinary object type 0. (Other types are 2=zone object, 3=particle emitter, 4=mover, 5=camera.) The properties for the special object to be created can be stored in a vlist that is passed to the @objectaddv function, or in a hex string representation of the data with the @objectadd function. In Magsbot version 7.3, the hex string can instead be an object data memory block, which is created using the @copydata, @datafromstr, @objdatafromvlist functions, or (within a CellObject event), @atr[object_data]. See here for more information.
@objectload[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,$datastr]
@objectload[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@objdata]
@objectloadv[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@vproperties]
@objectloadp[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@objdata]
Like @objectadd except also allows you to specify the object's owner (citizen number) and timestamp. The timestamp is a @ctime value.@objectchange[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,$datastr]
All of the "-id-" functions below are the same as the corresponding functions whose name lacks the "id", except that the "id" versions return (and take, in the case of @objectidchange and @objectidchangev) an object ID instead of an object number. And object ID is something new in AW 4.1. It functions similarly to an object number, except that unlike object numbers, and object ID doesn't change everytime an object is moved or altered, making object IDs more useful for keeping track of objects that are frequently changed. Also, an object can be deleted using the object id (OBJECTDELETE_ @objid) instead of using the object number (OBJECTDELETE @objnum @z @x), without having to know the object's location. (At least in theory...at the present time (Sept. 2006) I believe there is a bug in the aw_object_delete SDK function, that causes deletion using object id to fail.)
@objectchange[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
@objectchangev[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@vproperties]
@objectchangep[@old_obj_num,@old_ns,@old_we,@owner,@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
Changes an existing object and returns the new object number. Requires the current object number of the object (first argument), the current NS and WE coordinates (second and third arguments), and the object owner's citizen number (forth argument). The specified owner must be the same as the current object's owner, or someone with eminent domain in the world containing the object.
@objectidadd[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,$datastr]
@objectidadd[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
@objectidaddv[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@vproperties]
@objectidaddp[@ns,@we,@alt,@yaw,@tilt,@roll,$model,$desc,$action,@objtype,@objdata]
NOTE: Unlike @objectadd et al, the objectidadd functions DO NOT RETURN A CORRECT VALUE when the new object is created. The object id of the newly created object is available ONLY in the OBJECTRESULT callback. (This is true as of Magsbot version 7.4.3; but in earlier versions the value was wrong even in the callback, since I didn't realize that the object id is not correct immediately after the SDK function creates the object.) This is due to the way the SDK works, so there's nothing I can do about it. Whether it's a bug or not is a matter of opinion, since nothing says that the value has to be correct right after creating the new object, as long as you can get the value in the callback. However the object number (as opposed to object id), is reliable even immediately after creation, and I expected things to work the same with object id as it always has with object number....oops!
@objectidload[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,$datastr]
@objectidload[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@objdata]
@objectidloadv[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@vproperties]
@objectidloadp[@owner,@timestamp,@ns,@we,@alt,@yaw,@tilt,@roll$model,$desc,$action,@objtype,@objdata]
(See note for @objectidadd, above.)
@copydata[@objdata,@datalen]
Creates a copy of object data, for using with @objectadd, etc. Remember to free the memory when you are done with it, using FREEOBJDATA. Example: In a CELLOBJECT event: @@myobjdata=@copydata[@atr[object_data]]. Later: @newobj=@objectadd[...,@objdata]. Note: this function can use ANY character array as the source, not just an object data memory block. A new object data memory block is created for the output and should be freed (FREEOBJDATA) when no longer needed. The @datalen argument can be optional IF the data was created using a Magsbot function like @datafromstr of @objdatafromvlist.
@datalen[@objdata]
Returns the length of an object data memory block. (Will only work with object data from @atr[OBJECT_DATA] or created using a Magsbot function like @datafromstr or @objdatafromvlist.)
@datafromstr[$objdata]
Create an object data memory block from an object data hex string. A new object data memory block is created for the output and should be freed (FREEOBJDATA) when no longer needed.
$strfromdata[@objdata,@datalen]
Create an object data hex string from an object data memory block. Note: this function can use ANY character array as the source, not just an object data memory block. The @datalen argument can be optional IF the data was created using a Magsbot function like @datafromstr of @objdatafromvlist.
@byte[@objdata,@index]
The @byte function returns one byte of data from a block of data. Note: this function can use ANY character array as the source, not just an object data memory block.@objdatalen
Returns the length of object properties data (@atr[object_data]) in the context of a CELLOBJECT event. (Outside of the context of CELLOBJECT, use the @datalen[@objdata] function instead.)
$objdatastr
Gives the object properties data of an object in the form of a hexidecimal string, in the context of a CELLOBJECT event. (Outside of the context of CELLOBJECT, you can use the $strfromdata[@objdata] function.)
$objdatafromvlist[@objtype,@vlist]
Converts a vlist that contains special object properties for the specified object type, into a string of hexidecimal characters.
@objdatafromvlist[@objtype,@vlist]
Converts a vlist that contains special object properties for the specified object type, into an object data memory block. A new object data memory block is created for the output and should be freed (FREEOBJDATA) when no longer needed.@vlistfromobjdata[@objtype,$datastr]
Converts a string of hexidecimal characters that represents special object properties into a vlist containing variables assigned with those properties.
@vlistfromobjdata_[@objtype,@objdata]
Converts an object data memory block into a vlist containing variables representing the object's properties.
$olversion
Returns 2, 3 or 4 depending on the setting of the Options/Obj List Format menu item. (The setting of that menu item is used to specify what format the object list is in, when building from an object list or when saving and object list to a propdump file (as opposed to an object list file). The formats correspond to propdump versions: 2=no tilt/roll, 3=tilt/roll, 4=tilt/roll and special objects.)
@axis3
Returns true (1) if the Options/Obj List Format menu item is set to Version 3. (Meaning that when the bot the builds an object list, it will use the tilt and roll properties.)
@olver4
Returns true (1) if the Options/Obj List Format menu item is set to Version 4. (Meaning that when the bot the builds an object list, it will use the tilt and roll properties and the object type and object data properties.)
@reacted
Returns true (1) if the current Event has caused an Action to take place on any previous row of the Behavior Table. For example, you could have a row at the end of the Behavior Table containing the Event HEAR @reacted=0 and an Action that would only occur if no previous row of the table has caused a response to that event. Also see the ENDCHECK Action.$event[@row]
Returns an Event string from the behavior table, specified by row (top row is row 1). NOTE! If the event text is > 1k, it will be truncated.$action[@row]
Returns an Action string from the behavior table, specified by row (top row is row 1). NOTE! If the action text is > 1k, it will be truncated.@behcount
Returns a count of the number of rows in the behavior table.@behstate[@row]
Returns the "active" state (0 or 1) of the specified row of the behavior table.@eventtime
Valid only within a behavior table entry, this returns the time that the event occurred, in Delphi format (i.e., the same format as @time, @now, etc.)@timestamp
Valid only within a behavior table entry, this returns the time that the event occurred, in C format (i.e., the same format as @ctime, etc.) (As of version 2.9.4, this is a macro derived from @eventtime.)@eventtime
Valid only within a behavior table entry, this returns the time that the event occurred, in Delphi format.
@eventcount
The number of pending events in the event queue.@actcount
The number of pending actions in the action queue.
$btnact[$label]
Returns the action string (script) from the Action Button with the specified label.$btnact_[@n]
Returns the action string (script) from the Action Button with the specified index, base 1. (It was base 0 in some earlier versions.)$btnlabel_[@n]
Returns the label from the Action Button with the specified index, base 1. (It was base 0 in some earlier versions.)@isbtn[$label]
Returns true if an Action Button with the specified label exists. NOTE: if the $label doesn't include the category path to search in, the default . root tab will be assumed. The function will NOT find the button if the category name is not included and the button isn't in the default tab! The value returned will be the index of the button within the specified tab.@btncount
Returns a count of the number of Action Buttons.@btncount_[@tab]
Returns a count of the number of buttons on the specified Action buttons tab.@btntab[$name]
Returns the tab number of the button category of the specified name, or 0 if the tab isn't found.$btntab[@tab]
Returns the category name of the specified name Action buttons tab.$categorypath
Shows the search path for buttons. See SETCATEGORYPATH for details. (New in version 4.3.11.)
@error
Returns the most recent error code (or 0 if no error has occurred).$error
Returns the most recent error message (or empty string if no error has occurred).@sdkerror
Returns the most recent SDK error code (or 0 if no error has occurred).$sdkerror[@sdkerror]
Returns a message associated with a particular SDK error code.
Bone telegram system functions:
@berror
Bone error code$bwelcome
Welcome message, returned during a BWELCOME Event.@bstatus
Status, returned during a BSTATUS Event. (0=invalid, 1=off-line, 2=on-line)$bstatus
Name of the user returning status during a BSTATUS Event.@bping
Ping delay time in seconds, returned during a BPING Event.$bping
Name of the user returing a ping during a BPING Event.$bgram
Telegram text, during a BGRAM Event.$bsender
Name of telegram sender, during a BGRAM Event.
See database Actions for more information.
@dbopen[$provider,$connect,$table]
Opens a connection to a specified database and returns a handle used by the DATASET command. Use DBCLOSE to free the handle. The $provider argument has become optional in version 5.x (preserved for backward compatibility). In 5.x, you should specify the provider as part of the $connect string.$dbrecord
Returns a string with the names and values of all the fields of the current record.$dbfield[$fieldname]
Value of specified string field in current record.@dbfield[$fieldname]
Value of specified numeric field in current record.$dbrfield[@recnum,$fieldname]
Value of specified string field in the specified record.@dbrfield[@recnum,$fieldname]
Value of specified numeric field in the specified record.
@dbreccount
Number of records in the current table.@dbrecno
The current position in the table.@dbbof
True (non-0) if database pointer is at the beginning of the database.@dbeof
True (non-0) if database pointer is at the end of the database.@dbisempty
True (non-0) if the database is empty.@dbfindfirst[$criteria]
Moves the database pointer to the first location in the current table that matches the specified criteria. Returns 0 if fails, non-0 if successful. For example, to move to a record with a field named "HomeWorld" that contains the value "MyWorld", the criteria string would be "HomeWorld='MyWorld'". Note the use of the single quotes. Another example: to move to a record with a field named "ID" that contains the value 28777, the criteria string would be "ID=28777". No quotes are needed in the second case because it's a numeric field.@dbfindnext[$criteria]
Moves the database pointer to the next location in the current table that matches the specified criteria. Returns 0 if fails, non-0 if successful. (See @dbfindfirst for details concerning the criteria string.)@dbfindprev[$criteria]
Moves the database pointer to the previous location in the current table that matches the specified criteria. Returns 0 if fails, non-0 if successful. (See @dbfindfirst for details concerning the criteria string.)@dbfindlast[$criteria]
Moves the database pointer to the last location in the current table that matches the specified criteria. Returns 0 if fails, non-0 if successful. (See @dbfindfirst for details concerning the criteria string.)
$dbparam[$paramname]
Returns the value of a parameter in an SQL stored procedure, by name.
$dbparami[@paramindex]
Returns the value of a parameter in an SQL stored procedure, by index.
@dbparamcount
The number of parameters in an SQL stored procedure..