Category:Structure access: Difference between revisions
Hendricks266 (talk | contribs) No edit summary |
mNo edit summary |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
One of the hallmarks of EDuke32's CON scripting advancements is the ability to access many of the game's internal data structures. | |||
==Usage== | |||
Struct access was designed with the syntax of an array of a struct type in the C programming language. | |||
The index in <nowiki>[</nowiki>square brackets<nowiki>]</nowiki> is an ID number that has different meanings for different structs. Most simple uses of struct access will suffice to use the gamevar [[THISACTOR]] as an index, which usually means the current sprite but is also usable as a ''magic token'' for different meanings with non-sprite structures. Other times, you may know an ID from a command like [[findnearactor]] or [[espawn]] (from gamevar [[RETURN]]). On occasion you may also [[whilevarn|loop]] through all or a selection of ID numbers. | |||
===Getters & Setters=== | |||
Get/set commands are the original methods of CON struct access that date back to DOS EDuke. | |||
get<struct>[<id>].<[[Full list of structure members|member]]> <[[gamevar]]><br> | get<struct>[<id>].<[[Full list of structure members|member]]> <[[gamevar]]><br> | ||
set<struct>[<id>].<[[Full list of structure members|member]]> <value><br> | set<struct>[<id>].<[[Full list of structure members|member]]> <value><br> | ||
The '''get''' commands fetch one of the [[Full list of structure members|members of a structure]] into a [[gamevar]]. | The '''get''' commands fetch one of the [[Full list of structure members|members of a structure]] into a [[gamevar]]. | ||
The '''set''' commands assign the value provided to the member. | The '''set''' commands assign the value provided to the member. | ||
<id> can be omitted entirely, which implies an id of [[THISACTOR]]. | |||
The commands with the "var" suffix are used to access custom members for a struct, which are really just that ID's gamevars which have the per-<struct> flag set. So <code>setactorvar[THISACTOR].temp 0</code> is the same as <code>setvar temp 0</code>. | The commands with the "var" suffix are used to access custom members for a struct, which are really just that ID's gamevars which have the per-<struct> flag set. So <code>setactorvar[THISACTOR].temp 0</code> is the same as <code>setvar temp 0</code>. | ||
{| {{ | ===Quick Access=== | ||
! | |||
More recently added, structs can be used in place of gamevars, in the form <code><struct>[<id>].<[[Full list of structure members|member]]></code>. For example: | |||
[[ifvarg]] userdef[].[[executions]] 10000 | |||
{ | |||
[[redefinequote]] 117 You have way too much time on your hands. | |||
echo 117 | |||
} | |||
With quick access, structures are always read-only. Attempting to use a gamevar-writing command on a quick access structure will result in a compiler error. | |||
Quick struct access cannot be used as an index to other quick struct accesses. | |||
==Structs== | |||
{| {{prettytablebordered}} | |||
!Get/Set Name!!Quick Name!!ID type!![[THISACTOR]] meaning!!Description!!Notes | |||
|- | |- | ||
|[[Members of the sprite, hittype, and spriteext structures|actor]] | |[[Members of the sprite, hittype, and spriteext structures|actor]] | ||
|[[Members of the sprite, hittype, and spriteext structures|sprite]] | |||
|[[sprite id]] | |[[sprite id]] | ||
| | |current sprite | ||
|sprites and hittypes | |sprites and hittypes | ||
| | | | ||
|- | |- | ||
| | |colspan="2"|actorvar | ||
|[[sprite id]] | |[[sprite id]] | ||
| | |current sprite | ||
|per-actor gamevars | |||
| | |||
|- | |||
|colspan="2"|[[Members of the tsprite structure|tspr]] | |||
|[[sprite id]] | |||
|current sprite | |||
|sprites' display properties | |sprites' display properties | ||
|Can only be used within [[EVENT_ANIMATESPRITES]] on sprites with [[mdflags]] containing flag 16 | |Can only be used within [[EVENT_ANIMATESPRITES]] on sprites with [[mdflags]] containing flag 16. | ||
|- | |- | ||
|[[Members of the projectile structure|projectile]] | |colspan="2"|[[Members of the projectile structure|projectile]] | ||
|[[tile number]] | |[[tile number]] | ||
| | |(none) | ||
|projectile types | |projectile types | ||
| | | | ||
|- | |- | ||
|[[Members of the projectile structure|thisprojectile]] | |colspan="2"|[[Members of the projectile structure|thisprojectile]] | ||
|[[sprite id]] | |[[sprite id]] | ||
| | |current sprite | ||
|individual projectiles | |individual projectiles | ||
| | | | ||
|- | |- | ||
|[[Members of the sector structure|sector]] | |colspan="2"|[[Members of the sector structure|sector]] | ||
|[[sector id]] | |[[sector id]] | ||
| | |current sprite's sector | ||
|sectors, floors, and ceilings | |sectors, floors, and ceilings | ||
| | | | ||
|- | |- | ||
|[[Members of the wall structure|wall]] | |colspan="2"|[[Members of the wall structure|wall]] | ||
|[[wall id]] | |[[wall id]] | ||
| | |(none) | ||
|walls | |walls | ||
| | | | ||
|- | |- | ||
|[[Members of the player structure|player]] | |colspan="2"|[[Members of the player structure|player]] | ||
|[[ | |[[player id]] | ||
| | |current player | ||
|players | |players | ||
| | | getp can be used as a shorthand. | ||
|- | |||
|colspan="2"|playervar | |||
|[[player id]] | |||
|current player | |||
|per-player gamevars | |||
| getpv can be used as a shorthand. | |||
|- | |- | ||
|[[Members of the input structure|input]] | |colspan="2"|[[Members of the input structure|input]] | ||
|[[ | |[[player id]] | ||
| | |current player | ||
|input | |input | ||
|Generally used within [[EVENT_PROCESSINPUT]] | |Generally used within [[EVENT_PROCESSINPUT]]; geti can be used as a shorthand. | ||
|- | |- | ||
|[[Members of the userdef structure|userdef]] | |colspan="2"|[[Members of the userdef structure|userdef]] | ||
|(none) | |||
|(none) | |(none) | ||
|user preferences, game state | |user preferences, game state | ||
| | |Use nothing within the brackets; getu can be used as a shorthand. | ||
|- | |||
|colspan="2"|[[Members of the tiledata structure|tiledata]] | |||
|[[tile number]] | |||
|current sprite's picnum | |||
|art tiles | |||
| | |||
|- | |||
|(none) | |||
|[[Members of the paldata structure|paldata]] | |||
|[[palookup number]] | |||
|(none) | |||
|palette lookups (palswaps) | |||
| | |||
|} | |} | ||
[[Category:EDuke32 end-user documentation]] | [[Category:EDuke32 end-user documentation]] | ||
[[Category:Scripting documentation]] | [[Category:Scripting documentation]] |
Latest revision as of 02:01, 2 August 2020
One of the hallmarks of EDuke32's CON scripting advancements is the ability to access many of the game's internal data structures.
Usage
Struct access was designed with the syntax of an array of a struct type in the C programming language.
The index in [square brackets] is an ID number that has different meanings for different structs. Most simple uses of struct access will suffice to use the gamevar THISACTOR as an index, which usually means the current sprite but is also usable as a magic token for different meanings with non-sprite structures. Other times, you may know an ID from a command like findnearactor or espawn (from gamevar RETURN). On occasion you may also loop through all or a selection of ID numbers.
Getters & Setters
Get/set commands are the original methods of CON struct access that date back to DOS EDuke.
get<struct>[<id>].<member> <gamevar>
set<struct>[<id>].<member> <value>
The get commands fetch one of the members of a structure into a gamevar.
The set commands assign the value provided to the member.
<id> can be omitted entirely, which implies an id of THISACTOR.
The commands with the "var" suffix are used to access custom members for a struct, which are really just that ID's gamevars which have the per-<struct> flag set. So setactorvar[THISACTOR].temp 0
is the same as setvar temp 0
.
Quick Access
More recently added, structs can be used in place of gamevars, in the form <struct>[<id>].<member>
. For example:
ifvarg userdef[].executions 10000 { redefinequote 117 You have way too much time on your hands. echo 117 }
With quick access, structures are always read-only. Attempting to use a gamevar-writing command on a quick access structure will result in a compiler error.
Quick struct access cannot be used as an index to other quick struct accesses.
Structs
Get/Set Name | Quick Name | ID type | THISACTOR meaning | Description | Notes |
---|---|---|---|---|---|
actor | sprite | sprite id | current sprite | sprites and hittypes | |
actorvar | sprite id | current sprite | per-actor gamevars | ||
tspr | sprite id | current sprite | sprites' display properties | Can only be used within EVENT_ANIMATESPRITES on sprites with mdflags containing flag 16. | |
projectile | tile number | (none) | projectile types | ||
thisprojectile | sprite id | current sprite | individual projectiles | ||
sector | sector id | current sprite's sector | sectors, floors, and ceilings | ||
wall | wall id | (none) | walls | ||
player | player id | current player | players | getp can be used as a shorthand. | |
playervar | player id | current player | per-player gamevars | getpv can be used as a shorthand. | |
input | player id | current player | input | Generally used within EVENT_PROCESSINPUT; geti can be used as a shorthand. | |
userdef | (none) | (none) | user preferences, game state | Use nothing within the brackets; getu can be used as a shorthand. | |
tiledata | tile number | current sprite's picnum | art tiles | ||
(none) | paldata | palookup number | (none) | palette lookups (palswaps) |
Pages in category "Structure access"
The following 13 pages are in this category, out of 13 total.
M
- Members of the input structure
- Members of the paldata structure
- Members of the player structure
- Members of the player structure/test
- Members of the projectile structure
- Members of the sector structure
- Members of the sprite, hittype, and spriteext structures
- Members of the tiledata structure
- Members of the tsprite structure
- Members of the userdef structure
- Members of the userdef structure/WIP
- Members of the wall structure