User Tools

Site Tools


script:module:defs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
script:module:defs [2015-11-15 18:29] – external edit 127.0.0.1script:module:defs [2020-12-06 19:25] (current) skyjake
Line 1: Line 1:
 +====== Defs (Module) ======
 +
 +
 +The ''Defs'' module provides access to the definitions read from [[:DED]] files.
 +
 +<code>
 +$ dir(Defs)
 +⇒ [ SDN_ACTIVE, SDN_ATTACK, SDN_DEATH, SDN_PAIN, SDN_SEE, SN_CRASH,   SN_DEATH, SN_MELEE, SN_MISSILE, SN_PAIN, SN_RAISE, SN_SEE, SN_SPAWN, SN_XDEATH, decorations, episodes, finales, flags, mapInfos, materials, models, musics, skies, states, things ]
 +</code>
 +
 +
 +===== Lookups =====
 +
 +
 +Each collection of definitions contains various lookup tables and indices:
 +
 +
 +  $ dir(Defs.things)
 +  ⇒ [ idLookup, nameLookup, order ]
 +
 +
 +For example, ''idLookup'' is a dictionary that maps IDs to definition records.
 +
 +<code>
 +$ Defs.things.idLookup['possessed']
 +⇒ __order__:   1
 +  custom:      False
 +  damage:      0
 +  doomEdNum:   3004
 +  flags:       [ 0x400006, 0x40000, 0 ]
 +  height:      56
 +  id:          POSSESSED
 +  mass:        100
 +  misc:        [ 0, 0, 0, 0 ]
 +  name:        Zombieman
 +  painChance:  200
 +  radius:      20
 +  reactionTime:8
 +  sounds:      [ popain, podth1, posact, , posit1 ]
 +  spawnHealth: 20
 +  speed:       8
 +  states:      [ POSS_STND, POSS_RUN1, POSS_PAIN, NULL, POSS_ATK1, , POSS_DIE1, POSS_XDIE1, POSS_RAISE1 ]
 +</code>
 +
 +
 +===== Order =====
 +
 +
 +The ''order'' variable contains a regular array where the definitions are stored in the order they were read from the [[:DED]] files. The order is meaningful because generally later definitions override earlier ones. The indices in this list are also available in the definition records as ''<nowiki>__order__</nowiki>''.
 +
 +
 +  $ len(Defs.things.order)
 +  ⇒ 140
 +  $ Defs.things.order[1].id
 +  ⇒ POSSESSED
 +
 +
 +
 +===== Constants =====
 +
 +
 +The ''Defs.SN_*'' constants are used as indices in the ''states'' array of [[ded:thing|Thing definitions]].
 +
 +The ''Defs.SDN_*'' constants are used as indices in the ''sounds'' array of [[ded:thing|Thing definitions]].
 +
 +
 +
 +===== Functions =====
 +
 +The following return the internal index number for a given ID:
 +
 +#@Identifier_HTML~getSoundNum~@# ( #@Arg_HTML~Text,name~@# )
 +
 +#@Identifier_HTML~getStateNum~@# ( #@Arg_HTML~Text,stateId~@# )
 +
 +#@Identifier_HTML~getThingNum~@# ( #@Arg_HTML~Text,thingId~@# )