View Single Post
Old 04-06-2016   #133
MascaraSnake
aka SpiritCrusher
Moderator
 
MascaraSnake's Avatar
Default

v2.3 has been released!

The main focus of this release is script support: You can now edit SOC and Lua scripts in the script editor. All script lumps in the currently opened file are automatically opened in the script editor, as well as the MAINCFG and OBJCTCFG lumps (even if they don't yet exist). You can't add new lumps to the file though, because this isn't a lump editor. :P

The other big new feature is that Zone Builder now automatically recognizes custom Things that are defined in the Lua and SOC scripts of the currently loaded files. These custom Things are added to the list of Things so you can easily place them in the editor. By default, custom Things will show the "unknown sprite" graphic, but you can specify a real sprite with a special comment in the script itself:

For SOC lumps, add "#$Sprite <name>" as a line anywhere in the object type definition, where <name> is the lump name of the sprite you want to be displayed. The sprite can be located in the IWAD or any of the currently loaded files. Likewise, add "$Name <name>" to supply your own name for the object. Otherwise, it will be listed under the internal MT_ name. Here's an example:

Code:
Object MT_EXAMPLE
#$Name Example object
#$Sprite CUSTA3A7
MapThingNum = 1234
SpawnState = S_PLAY_STND
SpawnHealth = 1
SeeState = S_PLAY_RUN1
SeeSound = sfx_None
ReactionTime = 0
AttackSound = sfx_thok
PainState = S_PLAY_PAIN
PainChance = MT_THOK
PainSound = sfx_None
MeleeState = S_NULL
MissileState = S_PLAY_ATK1
DeathState = S_PLAY_DIE
XDeathState = S_NULL
DeathSound = sfx_None
Speed = 1
Radius = 16*FRACUNIT
Height = 48*FRACUNIT
DispOffset = 0
Mass = 1000
Damage = MT_THOK
ActiveSound = sfx_None
Flags = MF_SOLID|MF_SHOOTABLE
RaiseState = MT_THOK
For Lua lumps it's pretty much the same, except the lines are "//$Sprite <name>" and "//$Name <name>". Here's an example:

Code:
mobjinfo[MT_EXAMPLE] = 
	//$Sprite CUSTA3A7
        //$Name Example object
        doomednum = 1234,
        spawnstate = S_PLAY_STND,
        spawnhealth = 1,
        seestate = S_PLAY_RUN1,
        seesound = sfx_None,
        reactiontime = 0,
        attacksound = sfx_thok,
        painstate = S_PLAY_PAIN,
        painchance = MT_THOK,
        painsound = sfx_None,
        meleestate = S_NULL,
        missilestate = S_PLAY_ATK1,
        deathstate = S_PLAY_DIE,
        xdeathstate = S_NULL,
        deathsound = sfx_None,
        speed = 1,
        radius = 16*FRACUNIT,
        height = 48*FRACUNIT,
        dispoffset = 0,
        mass = 1000,
        damage = MT_THOK,
        activesound = sfx_None,
        flags = MF_SOLID|MF_SHOOTABLE,
        raisestate = MT_THOK
}
A few words of warning about this feature: The parsers I wrote for this are very rudimentary. I can't guarantee that they will accept every valid script and reject every invalid script. If you do unorthodox stuff in your object definitions, Zone Builder may fail to read them. If you have errors in parts of the scripts that aren't read by the parsers, Zone Builder will recognize them as valid even though SRB2 won't. I consider these parsers a luxury feature and I don't intend to support all the intricacies of these scripting languages, especially Lua. Feel free to report issues to me, but please be aware that I might not be able to fix all of them.

Here are a few known limitations of the custom Thing parsers:
  • Only long-form object definitions like the example above are recognized in Lua scripts. Short-form definitions where the parameter names are omitted aren't recognized.
  • The editor won't recognize statements that modify only a single entry of an already existing object type entry, e.g. "mobjinfo[MT_EXAMPLE].doomednum = -1".
  • Arithmetic operations aren't supported, except for multiplications with FRACUNIT in the Radius and Height fields.
  • The parsers don't check if you defined freeslots for your custom objects, so if your objects show up in Zone Builder but not in SRB2, that might be a reason.

Last edited by MascaraSnake; 05-24-2016 at 04:49 PM.
MascaraSnake is offline   Reply With Quote