Listing of New Script Stuff

Forum Archive - from http://theuniversal.net
Locked
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Listing of New Script Stuff

Post by zaroba »

This list is a compilation of the stuff mit has posted in the numerous update topics in the general forum.

If there is a (?) before the description it is because I am taking a guess as to what it means. Mit would have to confirm

================================
- Events
"BuildingDemolished" - (?) Runs when the specified building is demolished
"UseSkill" - (?) Runs when the player uses the specified skill
"PlayerRespawn" - (?) Runs when the player respawns
"BattleSurrender" - (?) Runs when the player surrenders during battle
"BattleLeave" - (?) Runs when the player leavs a battle (log off maybe?)
"ItemAdded" - (?) Runs when the specified item is added to inventory
"ItemRemoved" - (?) Runs when the specified item is removed from inventory
"BuildingProductionRun" - (?) Runs when the building goes thre a production cycle
"TaskStart" - (?) Start of a task
"TaskComplete" - (?) Runs when a task is finished
"RobocrowKilled" - (?) Runs when somebody kills you in a crow
"RobocrowKill" - (?) Runs when you kill somebody in a crow
"PlayerBirthday" - (?) Runs on the anniversary days of the players joining or respawning after death
"PlayerDeath" - USed to run when your killed by another player, now means when you die naturally
"PlayerKilled" - Runs when your killed by another player
"AccessBuilding" - (?) Runs when a player hits Control at a building to access it
"NewPlayer" - Runs before PlayerLogin when a new user record is created



- Variables
$gBuildingNum - alternative to $gBuildingAccessNum
$gBuildingX, $gBuildingY - gets the current buildings map position
$gBuildingCode - Gets the current buildings type
$gNearestBuildingCode - Gets the nearest buildings type
$gBuildingOwnerID - gets the ID of the owner for the current building
$gPlayerNumSkills - (?) The number of skilsl the player has
$gPlayerUsage - (?) The players usage
$gPlayerVar and $gPlayerTimeVar for consistency. ($PlayerVar etc will be deprecated)
$gPlayerAuth - (?) Auth level of the player
$gPlayerIsMember - (?) equals 1 if the player is a paying member
$gPlayerNumDeaths - (?) number of deaths the player has had
$gBuildingVar[1-16] - 16 vars that are per building instance, are associated with the building that activates the script
$gBuildingTimeVar[1-16] - 16 vars that are per building instance, are associated with the building that activates the script
$gPlayerFollowing - (?) ID of the person who the player is following (ie, the tribe leader)
$gPlayerNumFollowing - (?) Number of people following the player (ie, they are a tribe leader)
$gBuildingAccessNum - (?) The map id of the building accessed
$gPlayerID - Gets the billing ID of the player
$gPlayerHunger - (?) Players hunger
$gPlayerThirst - (?) Players Thirst
$gPlayerMaxHealth - (?) Maximum health value for the player
$gPlayerAge - (?) Age of the player
$gTaskItem1 - (?) Item needed for a task
$gTaskItem2 - (?) Item needed for a task
$gTaskItem3 - (?) Item needed for a task
$gBuildingScriptParam - Returns the value set by *buildingparam [BuildingRecordNum] [Param (0-255)]
$gPlayerRobocrowKills - (?) Number of times the player has killed somebody else in a robocrow
$gPlayerRobocrowDeaths - (?) Number of times the player has been killed in a robocrow
$gParams[1-16]

$gPlayerX - Gets the players map coordinates (0-255)
$gPlayerY - Gets the players map coordinates (0-255)
$gPlayerWorldX - Gets the players world coordinates (1-1048k, 4096 per tile)
$gPlayerWorldY - Gets the players world coordinates (1-1048k, 4096 per tile)


- Variable Functions ( $variable = function )
sysIsInTown - (?) Town the player is in (name I assume)
sysRealTime - (?) Real time of the player
Rand renamed to sysRand - Sets a variable to a specified randum number and can now take variables as parameters
sysGetBuyPrice(item) - (?) Tells the buy price of the specified item in the building that activates the script
sysGetSellPrice(item) - (?) Tells the sell price of the specified item in the building that activates the script
sysAmountInStocks("ItemName") - (?) Tells the quantity of the specified item in the building that activates the script
sysIsBuildingPositionValid - Equals 1 if its possible to build in this position, 0 if not
sysGetTextEntry - returns the text entered into a OSDTEXTENTRY dialog
AddToInventory("ITEM_NAME") - Equals 0 if the item couldn't be added

- Names
%TARGET% - Name the player has highlighted in the player menu
Last edited by zaroba on Wed Jun 13, 2012 10:05 am, edited 2 times in total.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Re: Listing of New Script Stuff

Post by morbydvisns »

zaroba wrote:If there is a (?) before the description it is because I am taking a guess as to what it means. Mit would have to confirm

- Events

"ItemAdded" - (?) Runs when the specified item is added to a building
"ItemRemoved" - (?) Runs when the specified item is removed from a building
"
"PlayerBirthday" - (?) Runs on the anniversary days of the players joining or respawning after death






$gPlayerWorldX - Gets the players map coordinates (0-255)
$gPlayerWorldY - Gets the players map coordinates (0-255)

Pretty much look all good at first glance, i left the ones that need expounding on..

itemadded and remove, are when a new item name is placed in inventory. Only the first item kicks this..
I assume Itemremoved is just the opposite.

Birthday event is like the old school birthday announcement except an event.

$gPlayerWorldX and Y, give more points of refrence.. there are I believe 4096 points to each of the 256 tiles, for more fine tuned placement of things. goes from 0 - to like 1048k+



good stuff, all of it.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

ty morvis.
wasn't the oldschool birthday thing the same? it popped up the message on anniversary dates of joining.


I also have lists of all new commands, settings, etc.
Just need to clean them up a bit.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

can you both bump me an email to remind me to get you accounts set up on the wiki, then you can edit that yourselves. (At work atm and don't have access to all my admin stuff). I also need to do it when i get home and check email, rather than when i've started coding and met you in game, by which point setting up admin accounts on wikis is not an acceptable use of my time ;]

That's assuming you're happy to update the wiki for us, of course :)
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

p.s. with regard to all the (?) items.. nothing majorly wrong with any of those assumptions :) (Which is obviously a good sign, as they should be mostly self-evident where possible).

Few little notes :

$gPlayerUsage is usage in hours.

$gTaskItem1, $gTaskItem2 etc are the item currently being 'used' in a task, and are also used as task codes in some of the other tasking mechanisms.
e.g. Some of the civ building scripts do this kinda thing :

Code: Select all

*dobuildingtask %PLAYER% $gBuildingAccessNum 3 Baking some bread
the '3' is used as a code to identify the task, and the 'TaskComplete' event picks that up like:

Code: Select all

//  Type 2 = Building tasks	   (*dobuildingtask)
Event( "TaskComplete", "2" )
{		
    if ( $gTaskItem1 == 3 )
   {
       $ret = BakeryTaskComplete()
   }
}
TaskComplete comes in 3 flavours atm..
Type 0 = Combining multiple items together (like revelations)
Type 1 = 'Standard' scripted tasks triggered using *dotask
Type 2 = Building tasks triggered using *dobuildingtask

The tasking system(s) need their own comprehensive documentation page, and i'll probably add new variable names to avoid the duplication of use.

sysIsInTown returns 1 or 0 dependin on whether you're currently in town limits or not. (Its mostly intended for custom construction scripts atm.. may be more useful if it returned the town ID num or 0).

AddToInventory is now sysAddToInventory. (the 'sys' bit will be reserved for all system calls, to avoid me fecking up your scripts by adding in a new system function name that you might happen to have been using for your own custom function).

Latest additions by the way (not yet on the wiki or release notes..)

System values
$gBuildingNumEmployees
$gBuildingMaxEmployees
$gBuildingSalePrice
$gPlayerNumJobs
$gGameDay
Events:
AccessConstruction
BuildingDemolished
UseSkill
BuildingOwnerDied
SkillAdded
SkillRemoved
System functions
sysGetPlayerName
sysGetItemName
sysGetSkillName
sysGetEmployeeID

which should all be pretty much self-explanatory, right? :)
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

hmm....is the BuildingProductionRun event something that goes by building bdat id and does it run for each instance of a building on the world using the buildingvars for that building?
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

that is correct zar. The *Settings/economy/global production rate I believe it is, sets the frequency. 1 is every 10 second, 2 is 20, etc. Every building instance on the map for that id runs the event.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

hey mit can we get the dotask type command syntax plz?
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

O and also SetContext

I'm hoping this can work with buildings too.. I've played with it a bit but havn't found any good guesses on how to use it properly
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

$gNearestBuildingX, and Y
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

dotask is:

Code: Select all

*dotask [PLAYER_ID] [TASK_CODE] [TEXT]
with the task events getting a param of 1 and the TASK_CODE stored in $gTaskItem1, i.e.

Code: Select all

Event( "TaskComplete", "1" )
{		
    if ( $gTaskItem1 == 101 )
    {
        $ret = ClayMakingPotTaskComplete()
    }
}
which'd be triggered by something like

Code: Select all

*dotask %PLAYER% 101 Making a clay pot
SetContext is immensely useful but only works for some variables atm and may need its format changing later (hence why its not currently documented). Setting the context changes the current 'player' being referenced, so you can do things like this:

Code: Select all

Event( "InitChallenge", "" )
{
     $challengerWisdom = $gPlayerKudos
		
     SetContext( $gTargetID )
     $targetWisdom = $gPlayerKudos
     RestoreContext()
Which gets you the kudos/wisdom of the player who started a challenge and the target of that challenge.

Currently this only applies to $gPlayer... variables. SetBuildingContext (and RestoreBuildingContext) are on the list.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

played around with *dotask a bit.. it wants player name. What determines time length of the task though?
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

yeh, %PLAYER% is the player name in the example.

Task time is set in the TaskStart event using PlayerTaskStartSetTime with the param indicating the number of seconds the task will take, e.g.

Code: Select all

Event( "TaskStart", "1" )
{
    if ( $gTaskItem1 == 101 )
    {
        PlayerTaskStartSetTime(20)
    }
}
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

righton musta blew right past the example i just noticed the player_id part in the first.. used to id beingthe num for setowner =). wasnt there one for multiple task items too
Locked