Difference between revisions of "Legacy:Functions/Map/Entities"
From Spherical
< Legacy:Functions | Map
(created, needs reformatting) |
(Reformat for new convention) |
||
Line 1: | Line 1: | ||
− | + | '''NOTE''': Entities are known in script as "persons" for legacy reasons. | |
− | * [[CreatePerson]](''name'', ''spriteset'', ''destroy_with_map''): Create a new person called ''name'' with ''spriteset'' (filename). | + | * [[API:GetPersonList|GetPersonList]](): Get an array of all named persons on the current map. |
− | * [[DestroyPerson]](''name''): Destroy the person called ''name''. | + | * [[API:CreatePerson|CreatePerson]](''name'', ''spriteset'', ''destroy_with_map''): Create a new person called ''name'' with ''spriteset'' (filename). |
+ | * [[API:DestroyPerson|DestroyPerson]](''name''): Destroy the person called ''name''. | ||
+ | * [[API:FollowPerson|FollowPerson]](''name'', ''leader'', ''pixels''): Makes a sprite follow behind another sprite. | ||
− | ==== | + | ==== Entity position ==== |
− | * [[GetPersonX]](''name''): Get the map X coordinate of ''name''. | + | * [[API:GetPersonX|GetPersonX]](''name''): Get the map X coordinate of ''name''. |
− | * [[GetPersonY]](''name''): Get the map Y coordinate of ''name''. | + | * [[API:GetPersonY|GetPersonY]](''name''): Get the map Y coordinate of ''name''. |
− | * [[GetPersonLayer]](''name''): Get the map layer index of ''name''. | + | * [[API:GetPersonLayer|GetPersonLayer]](''name''): Get the map layer index of ''name''. |
− | * [[SetPersonX]](''name'', ''x''): Set the map X of ''name'' to ''x''. | + | * [[API:SetPersonX|SetPersonX]](''name'', ''x''): Set the map X of ''name'' to ''x''. |
− | * [[SetPersonY]](''name'', ''y''): Set the map Y of ''name'' to ''y''. | + | * [[API:SetPersonY|SetPersonY]](''name'', ''y''): Set the map Y of ''name'' to ''y''. |
− | * [[SetPersonLayer]](''name'', ''layer''): Set the map layer of ''name'' to ''layer''. | + | * [[API:SetPersonLayer|SetPersonLayer]](''name'', ''layer''): Set the map layer of ''name'' to ''layer''. |
− | * [[GetPersonXFloat]](''name''): Get the map X of ''name'' to floating point accuracy. | + | * [[API:GetPersonXFloat|GetPersonXFloat]](''name''): Get the map X of ''name'' to floating point accuracy. |
− | * [[GetPersonYFloat]](''name''): Get the map Y of ''name'' to floating point accuracy. | + | * [[API:GetPersonYFloat|GetPersonYFloat]](''name''): Get the map Y of ''name'' to floating point accuracy. |
− | * [[SetPersonXYFloat]](''name'', ''x'', ''y''): Set the position of ''name'' with floating point accuracy. | + | * [[API:SetPersonXYFloat|SetPersonXYFloat]](''name'', ''x'', ''y''): Set the position of ''name'' with floating point accuracy. |
==== Directions and animations ==== | ==== Directions and animations ==== | ||
− | * [[GetPersonDirection]](''name''): Get the animation direction of person ''name''. | + | * [[API:GetPersonDirection|GetPersonDirection]](''name''): Get the animation direction of person ''name''. |
− | * [[SetPersonDirection]](''name'', ''direction''): Set animation direction of person ''name'' to ''direction''. | + | * [[API:SetPersonDirection|SetPersonDirection]](''name'', ''direction''): Set animation direction of person ''name'' to ''direction''. |
− | * [[GetPersonFrame]](''name''): gets the frame and direction that are currently being displayed. | + | * [[API:GetPersonFrame|GetPersonFrame]](''name''): gets the frame and direction that are currently being displayed. |
− | * [[SetPersonFrame]](''name'', ''frame''): sets which frame from which direction to display. | + | * [[API:SetPersonFrame|SetPersonFrame]](''name'', ''frame''): sets which frame from which direction to display. |
− | * [[SetPersonFrameRevert]](''name'', ''delay''): sets the delay between when the person last moved and returning to first frame. | + | * [[API:SetPersonFrameRevert|SetPersonFrameRevert]](''name'', ''delay''): sets the delay between when the person last moved and returning to first frame. |
− | * [[GetPersonFrameRevert]](''name''): gets the delay between when the person last moved and returning to first frame. | + | * [[API:GetPersonFrameRevert|GetPersonFrameRevert]](''name''): gets the delay between when the person last moved and returning to first frame. |
==== Movement speed ==== | ==== Movement speed ==== | ||
− | * [[ | + | * [[API:GetPersonSpeedX|GetPersonSpeedX]](''name''): gets a person's x speed. |
− | * [[ | + | * [[API:GetPersonSpeedY|GetPersonSpeedY]](''name''): gets a person's y speed. |
− | * [[ | + | * [[API:SetPersonSpeed|SetPersonSpeed]](''name'', ''speed''): sets the person's speed. |
− | * [[ | + | * [[API:SetPersonSpeedXY|SetPersonSpeedXY]](''name'', ''speed_x'', ''speed_y''): sets the person's x and y speed independently. |
==== Appearance ==== | ==== Appearance ==== | ||
− | + | * [[API:GetPersonOffsetX|GetPersonOffsetX]](name): gets the horizontal offset used for blitting frames | |
− | + | * [[API:SetPersonOffsetX|SetPersonOffsetX]](name, x): sets the horizontal offset to use for blitting frames; e.g. setting it to 10 would result in the person frame blitted always 10 pixels to the right, while the person's x-position would remain unchanged. | |
+ | * [[API:GetPersonOffsetY|GetPersonOffsetY]](name): gets the vertical offset used for blitting frames | ||
+ | * [[API:SetPersonOffsetY|SetPersonOffsetY]](name, y): sets the vertical offset to use for blitting frames; e.g. setting it to 10 would result in the person frame blitted always 10 pixels to the bottom, while the person's y-position would remain unchanged. | ||
+ | * [[API:GetPersonAngle|GetPersonAngle]](''name''): Get the rotation angle of the person ''name''. | ||
+ | * [[API:SetPersonAngle|SetPersonAngle]](''name'', ''angle''): Set the rotation angle of person ''name'' to ''angle'' radians. | ||
− | + | * [[API:GetPersonMask|GetPersonMask]](''name''): Get the masking [[API:Color|color]] of the person ''name''. | |
− | + | * [[API:SetPersonMask|SetPersonMask]](''name'', ''color''): Set the color-channel multiplying mask ''[[API:Color|color]]'' of the person ''name''. | |
− | |||
− | |||
− | + | * [[API:SetPersonScaleFactor|SetPersonScaleFactor]](''name'', ''scale_w'', ''scale_h''): Rescales the sprite of person ''name'' by relative factors ''scale_w'' and ''scale_h''. | |
− | + | * [[API:SetPersonScaleAbsolute|SetPersonScaleAbsolute]](''name'', ''width'', ''height''): Rescales the sprite of person ''name'' to ''width'' * ''height'' pixels. | |
− | + | * [[API:GetPersonSpriteset]](''name''): Get the spriteset of person ''name''. | |
− | + | * [[API:SetPersonSpriteset]](''name'', ''spriteset''): Set the spriteset of person ''name'' to ''spriteset'' (Sphere [[Object-Spriteset|Spriteset]] object). | |
− | |||
− | |||
− | * [[ | + | * [[API:IsPersonVisible|IsPersonVisible]](''name''): Check if the person with ''name'' is visible or not. |
− | + | *: <code>true</code>: visible, <code>false</code>: not visible. | |
− | + | * [[API:SetPersonVisible|SetPersonVisible]](''name'', ''visible''): Make person ''name'' visible or invisible. | |
− | + | *: <code>true</code>: visible, <code>false</code>: not visible. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | * [[SetPersonVisible]](''name'', ''visible''): Make person ''name'' visible or invisible. <code>true</code>: visible, <code>false</code>: not visible. | ||
==== Obstruction ==== | ==== Obstruction ==== | ||
+ | * [[API:GetPersonBase|GetPersonBase]](''name''): Get a person's [[API:Base|spriteset obstruction base]]. | ||
+ | * [[API:IsPersonObstructed|IsPersonObstructed]](''name'', ''x'', ''y''): Check if person "''name''" would be obstructed at (''x'', ''y''). | ||
− | * [[ | + | * [[API:IgnoreTileObstructions|IgnoreTileObstructions]](''person'', ''ignore''): Sets whether person "''person''" ignores tile obstructions. |
− | + | * [[API:IsIgnoringTileObstructions|IsIgnoringTileObstructions]](''person''): Checks whether "''person''" is ignoring tile obstructions. | |
− | |||
− | |||
− | |||
− | |||
− | * [[IsIgnoringTileObstructions]](''person''): Checks whether "''person''" is ignoring tile obstructions. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | * [[API:GetObstructingTile|GetObstructingTile]](name, x, y): returns the tile index of the tile if name is obstructed at x, y | |
− | + | *: returns -1 if name isn't obstructed by a tile at x, y, | |
− | + | * [[API:GetObstructingPerson|GetObstructingPerson]](name, x, y): returns the name of the person if name is obstructed at x, y | |
− | + | *: returns "" if name isn't obstructed by any person at x, y, | |
− | + | * [[API:IgnorePersonObstructions|IgnorePersonObstructions]](person, ignore): Sets whether 'person' should ignore other spriteset bases | |
− | + | * [[API:IsIgnoringPersonObstructions|IsIgnoringPersonObstructions]](person): Returns true if 'person' is ignoring person obstructions, else false | |
− | + | * [[API:GetPersonIgnoreList|GetPersonIgnoreList]](person): Returns a list of people that 'name' is ignoring | |
+ | * [[API:SetPersonIgnoreList|SetPersonIgnoreList]](person, ignore_list): Tells 'person' to ignore everyone in ignore_list; e.g. <code>SetPersonIgnoreList("White-Bomberman", ["bomb", "powerup"]);</code> tells White-Bomberman to not be obstructed by bombs or powerups | ||
==== Talk interaction ==== | ==== Talk interaction ==== | ||
+ | * [[API:SetTalkActivationKey|SetTalkActivationKey]](key): set key used to activate talk scripts | ||
+ | * [[API:GetTalkActivationKey|GetTalkActivationKey]](): return the key code used to activate talk scripts | ||
+ | * [[API:SetTalkDistance|SetTalkDistance]](pixels): set maximum distance to check for talk script activation | ||
+ | * [[API:GetTalkDistance|GetTalkDistance]](): return the maximum distance to check for talk script activation | ||
− | + | ==== Entity data ==== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ==== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ==== | + | * [[API:GetPersonData|GetPersonData]](name): gets a data object associated with the person 'name' |
+ | *: There are certain default properties/values filled in by the engine, they are: | ||
+ | *:: <var>num_frames</var> - the number of frames for the person's current direction | ||
+ | *:: <var>num_directions</var> - the number of directions for the person | ||
+ | *:: <var>width</var> - the width of the spriteset's current frame | ||
+ | *:: <var>height</var> - the height of the spriteset's current frame | ||
+ | *:: <var>leader</var> - the person that this person is following, or "" if no-one... | ||
+ | *: Any other properties are free for you to fill with values, e.g.<br/><syntaxhighlight>var data = GetPersonData("Jimmy"); var num_frames = data["num_frames"];</syntaxhighlight> | ||
+ | * [[API:SetPersonData|SetPersonData]](name, data): sets the 'data' object associated with the person 'name'; e.g.<br/><syntaxhighlight>var data = GetPersonData("Jimmy"); data["talked_to_jimmy"] = true; SetPersonData("Jimmy", data); </syntaxhighlight> | ||
+ | * [[API:SetPersonValue|SetPersonValue]](name, key, value)<br/>- SetPersonValue("Jimmy", "talked_to_jimmy", true); // same as code above | ||
+ | * [[API:GetPersonValue|GetPersonValue]](name, key)<br/>- GetPersonValue("Jimmy", "num_frames"); // same as previous code above | ||
− | + | ==== Controlling entities in script ==== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | * [[GetCurrentPerson]]() | + | * [[API:GetCurrentPerson|GetCurrentPerson]]() |
+ | * [[API:SetPersonScript|SetPersonScript]](name, which, script) | ||
+ | ** Available Person scripts: | ||
+ | **: <var>SCRIPT_ON_CREATE</var> | ||
+ | **: <var>SCRIPT_ON_DESTROY</var> | ||
+ | **: <var>SCRIPT_ON_ACTIVATE_TOUCH</var> | ||
+ | **: <var>SCRIPT_ON_ACTIVATE_TALK</var> | ||
+ | **: <var>SCRIPT_COMMAND_GENERATOR</var> | ||
+ | * [[API:CallPersonScript|CallPersonScript]](name, which) | ||
− | * [[QueuePersonCommand]](''name'', ''command'', ''immediate''): add a command to the person's command queue. | + | * [[API:QueuePersonCommand|QueuePersonCommand]](''name'', ''command'', ''immediate''): add a command to the person's command queue. |
− | * Person commands: | + | ** Available Person commands: |
− | ** <var>COMMAND_WAIT</var> | + | **: <var>COMMAND_WAIT</var> |
− | ** <var>COMMAND_ANIMATE</var> | + | **: <var>COMMAND_ANIMATE</var> |
− | ** <var>COMMAND_FACE_NORTH</var> | + | **: <var>COMMAND_FACE_NORTH</var> |
− | ** <var>COMMAND_FACE_NORTHEAST</var> | + | **: <var>COMMAND_FACE_NORTHEAST</var> |
− | ** <var>COMMAND_FACE_EAST</var> | + | **: <var>COMMAND_FACE_EAST</var> |
− | ** <var>COMMAND_FACE_SOUTHEAST</var> | + | **: <var>COMMAND_FACE_SOUTHEAST</var> |
− | ** <var>COMMAND_FACE_SOUTH</var> | + | **: <var>COMMAND_FACE_SOUTH</var> |
− | ** <var>COMMAND_FACE_SOUTHWEST</var> | + | **: <var>COMMAND_FACE_SOUTHWEST</var> |
− | ** <var>COMMAND_FACE_WEST</var> | + | **: <var>COMMAND_FACE_WEST</var> |
− | ** <var>COMMAND_FACE_NORTHWEST</var> | + | **: <var>COMMAND_FACE_NORTHWEST</var> |
− | ** <var>COMMAND_MOVE_NORTH</var> | + | **: <var>COMMAND_MOVE_NORTH</var> |
− | ** <var>COMMAND_MOVE_EAST</var> | + | **: <var>COMMAND_MOVE_EAST</var> |
− | ** <var>COMMAND_MOVE_SOUTH</var> | + | **: <var>COMMAND_MOVE_SOUTH</var> |
− | ** <var>COMMAND_MOVE_WEST</var> | + | **: <var>COMMAND_MOVE_WEST</var> |
− | * [[QueuePersonScript]](''name'', ''script'', ''immediate''): Queue a script command on the command queue of ''name''. | + | * [[API:QueuePersonScript|QueuePersonScript]](''name'', ''script'', ''immediate''): Queue a script command on the command queue of ''name''. |
− | * [[IsCommandQueueEmpty]](''name''): Check if the command queue of the person is empty. | + | * [[API:IsCommandQueueEmpty|IsCommandQueueEmpty]](''name''): Check if the command queue of the person is empty. |
− | * [[ClearPersonCommands]](name): Clears the command queue of the named person. | + | * [[API:ClearPersonCommands|ClearPersonCommands]](name): Clears the command queue of the named person. |
Revision as of 00:28, 2 June 2013
NOTE: Entities are known in script as "persons" for legacy reasons.
- GetPersonList(): Get an array of all named persons on the current map.
- CreatePerson(name, spriteset, destroy_with_map): Create a new person called name with spriteset (filename).
- DestroyPerson(name): Destroy the person called name.
- FollowPerson(name, leader, pixels): Makes a sprite follow behind another sprite.
Contents
Entity position
- GetPersonX(name): Get the map X coordinate of name.
- GetPersonY(name): Get the map Y coordinate of name.
- GetPersonLayer(name): Get the map layer index of name.
- SetPersonX(name, x): Set the map X of name to x.
- SetPersonY(name, y): Set the map Y of name to y.
- SetPersonLayer(name, layer): Set the map layer of name to layer.
- GetPersonXFloat(name): Get the map X of name to floating point accuracy.
- GetPersonYFloat(name): Get the map Y of name to floating point accuracy.
- SetPersonXYFloat(name, x, y): Set the position of name with floating point accuracy.
Directions and animations
- GetPersonDirection(name): Get the animation direction of person name.
- SetPersonDirection(name, direction): Set animation direction of person name to direction.
- GetPersonFrame(name): gets the frame and direction that are currently being displayed.
- SetPersonFrame(name, frame): sets which frame from which direction to display.
- SetPersonFrameRevert(name, delay): sets the delay between when the person last moved and returning to first frame.
- GetPersonFrameRevert(name): gets the delay between when the person last moved and returning to first frame.
Movement speed
- GetPersonSpeedX(name): gets a person's x speed.
- GetPersonSpeedY(name): gets a person's y speed.
- SetPersonSpeed(name, speed): sets the person's speed.
- SetPersonSpeedXY(name, speed_x, speed_y): sets the person's x and y speed independently.
Appearance
- GetPersonOffsetX(name): gets the horizontal offset used for blitting frames
- SetPersonOffsetX(name, x): sets the horizontal offset to use for blitting frames; e.g. setting it to 10 would result in the person frame blitted always 10 pixels to the right, while the person's x-position would remain unchanged.
- GetPersonOffsetY(name): gets the vertical offset used for blitting frames
- SetPersonOffsetY(name, y): sets the vertical offset to use for blitting frames; e.g. setting it to 10 would result in the person frame blitted always 10 pixels to the bottom, while the person's y-position would remain unchanged.
- GetPersonAngle(name): Get the rotation angle of the person name.
- SetPersonAngle(name, angle): Set the rotation angle of person name to angle radians.
- GetPersonMask(name): Get the masking color of the person name.
- SetPersonMask(name, color): Set the color-channel multiplying mask color of the person name.
- SetPersonScaleFactor(name, scale_w, scale_h): Rescales the sprite of person name by relative factors scale_w and scale_h.
- SetPersonScaleAbsolute(name, width, height): Rescales the sprite of person name to width * height pixels.
- API:GetPersonSpriteset(name): Get the spriteset of person name.
- API:SetPersonSpriteset(name, spriteset): Set the spriteset of person name to spriteset (Sphere Spriteset object).
- IsPersonVisible(name): Check if the person with name is visible or not.
-
true
: visible,false
: not visible.
-
- SetPersonVisible(name, visible): Make person name visible or invisible.
-
true
: visible,false
: not visible.
-
Obstruction
- GetPersonBase(name): Get a person's spriteset obstruction base.
- IsPersonObstructed(name, x, y): Check if person "name" would be obstructed at (x, y).
- IgnoreTileObstructions(person, ignore): Sets whether person "person" ignores tile obstructions.
- IsIgnoringTileObstructions(person): Checks whether "person" is ignoring tile obstructions.
- GetObstructingTile(name, x, y): returns the tile index of the tile if name is obstructed at x, y
- returns -1 if name isn't obstructed by a tile at x, y,
- GetObstructingPerson(name, x, y): returns the name of the person if name is obstructed at x, y
- returns "" if name isn't obstructed by any person at x, y,
- IgnorePersonObstructions(person, ignore): Sets whether 'person' should ignore other spriteset bases
- IsIgnoringPersonObstructions(person): Returns true if 'person' is ignoring person obstructions, else false
- GetPersonIgnoreList(person): Returns a list of people that 'name' is ignoring
- SetPersonIgnoreList(person, ignore_list): Tells 'person' to ignore everyone in ignore_list; e.g.
SetPersonIgnoreList("White-Bomberman", ["bomb", "powerup"]);
tells White-Bomberman to not be obstructed by bombs or powerups
Talk interaction
- SetTalkActivationKey(key): set key used to activate talk scripts
- GetTalkActivationKey(): return the key code used to activate talk scripts
- SetTalkDistance(pixels): set maximum distance to check for talk script activation
- GetTalkDistance(): return the maximum distance to check for talk script activation
Entity data
- GetPersonData(name): gets a data object associated with the person 'name'
- There are certain default properties/values filled in by the engine, they are:
- num_frames - the number of frames for the person's current direction
- num_directions - the number of directions for the person
- width - the width of the spriteset's current frame
- height - the height of the spriteset's current frame
- leader - the person that this person is following, or "" if no-one...
- Any other properties are free for you to fill with values, e.g.
var data = GetPersonData("Jimmy"); var num_frames = data["num_frames"];
- There are certain default properties/values filled in by the engine, they are:
- SetPersonData(name, data): sets the 'data' object associated with the person 'name'; e.g.
var data = GetPersonData("Jimmy"); data["talked_to_jimmy"] = true; SetPersonData("Jimmy", data);
- SetPersonValue(name, key, value)
- SetPersonValue("Jimmy", "talked_to_jimmy", true); // same as code above - GetPersonValue(name, key)
- GetPersonValue("Jimmy", "num_frames"); // same as previous code above
Controlling entities in script
- GetCurrentPerson()
- SetPersonScript(name, which, script)
- Available Person scripts:
- SCRIPT_ON_CREATE
- SCRIPT_ON_DESTROY
- SCRIPT_ON_ACTIVATE_TOUCH
- SCRIPT_ON_ACTIVATE_TALK
- SCRIPT_COMMAND_GENERATOR
- Available Person scripts:
- CallPersonScript(name, which)
- QueuePersonCommand(name, command, immediate): add a command to the person's command queue.
- Available Person commands:
- COMMAND_WAIT
- COMMAND_ANIMATE
- COMMAND_FACE_NORTH
- COMMAND_FACE_NORTHEAST
- COMMAND_FACE_EAST
- COMMAND_FACE_SOUTHEAST
- COMMAND_FACE_SOUTH
- COMMAND_FACE_SOUTHWEST
- COMMAND_FACE_WEST
- COMMAND_FACE_NORTHWEST
- COMMAND_MOVE_NORTH
- COMMAND_MOVE_EAST
- COMMAND_MOVE_SOUTH
- COMMAND_MOVE_WEST
- Available Person commands:
- QueuePersonScript(name, script, immediate): Queue a script command on the command queue of name.
- IsCommandQueueEmpty(name): Check if the command queue of the person is empty.
- ClearPersonCommands(name): Clears the command queue of the named person.