User:Monster Iestyn/2.1 to 2.2 Lua migration guide

From SRB2 Wiki
Jump to navigation Jump to search

Direct replacements:

2.1 2.2
thinkers.iterate("mobj") mobjs.iterate()
mobj.flags & MF_AMBUSH mobj.flags2 & MF2_AMBUSH
mobj.flags2 & MF2_STANDONME (can you stand on this object?) mobj.flags & MF_SOLID (solid objects now let you stand on them by default unlike in 2.1)
mobj.flags2 & MF2_PUSHED mobj.eflags & MFE_PUSHED
player.mo.health - 1

or

player.health - 1

(for getting ring count)

player.rings

(note: player.mo.health still exists but is only ever 1 or 0 now, to indicate if the player is alive or dead)

player.pflags & PF_ITEMHANG player.powers[pw_carry] == CR_GENERIC
player.pflags & PF_CARRIED player.powers[pw_carry] == CR_PLAYER
player.pflags & PF_ROPEHANG player.powers[pw_carry] == CR_ROPEHANG
player.pflags & PF_MACESPIN player.powers[pw_carry] == CR_MACESPIN
player.pflags & PF_NIGHTSMODE player.powers[pw_carry] == CR_NIGHTSMODE
player.pflags & PF_NIGHTSFALL player.powers[pw_carry] == CR_NIGHTSFALL
player.powers[pw_ingoop] != 0 player.powers[pw_carry] == CR_BRAKGOOP
ffloor.flags & FF_ONLYKNUX ffloor.flags & FF_STRONGBUST
P_Random() P_RandomByte()
P_DamageMobj(target, inflictor, source, 10000) (for insta-killing players) P_DamageMobj(target, inflictor, source, 1, DMG_INSTAKILL)
P_DamageMobj(target, inflictor, source, 42000) (for insta-killing spectators) P_DamageMobj(target, inflictor, source, 1, DMG_SPECTATOR)
P_CheckSolidLava(mo, rover) P_CheckSolidLava(rover)

Technically still working but with better alternatives:

2.1 2.2
player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT (are we in a zoomtube?) player.powers[pw_carry] == CR_ZOOMTUBE
v.cachePatch("THOKA0") (getting a regular sprite patch for HUD code)

v.getSpritePatch(SPR_THOK, 0, 0)

or (the prefix can be given as a string in the first argument)

v.getSpritePatch("THOK", 0, 0)

or (since this is frame 0, angle 0)

v.getSpritePatch(SPR_THOK)

or

v.getSpritePatch("THOK")

(note: for player sprites, use v.getSpritePatch2)

P_ElementalFireTrail(player) P_ElementalFire(player)