Lua polyobjects
Lua now has access to polyobj_t in this branch:
polyobj_t struct:
-
.valid(boolean): checks validity -
.id(int32): the ID used to reference the PolyObject in the map -
.parent(int32): the ID of the parent PolyObject, or -1 if it doesn't have one -
.vertices(vertex_tarray): an array containing all the PolyObject's vertices. Use#polyobj.verticesto get the number of vertices it has. -
.lines(line_tarray): an array containing all the PolyObject's linedefs. Use#polyobj.linesto get the number of lines it has. -
.sector(sector_t): the PolyObject's control sector. (The game usespolyobj.lines[0].backsectorinternally, but I figured it'd be much more convenient to have a variable to grab it directly for Lua at least) -
.angle(angle_t): the PolyObject's angle -
.damage(int32): not entirely sure how this works exactly, but if it's non-zero then the PolyObject can crush players -
.thrust(fixed_t): amount of thrust applied to objects that block the PolyObject's movement. By default this is set toFRACUNIT, but it may be modified by some of the linedef executor actions for PolyObjects -
.flags(int32): the PolyObject's flags (seePOF_list below) -
.translucency(int32): the PolyObject's translucency level, as a number from 0-9 -
.triggertag(int32): Tag of linedef executor to trigger on touch -
:pointInside(x, y): special function to check if a XY position is inside the bounds of the PolyObject -
:mobjTouching(mobj): special function to check if a mobj's XY position intersects with the lines of the PolyObject -
:mobjInside(mobj): special function to check if a mobj's XY position is inside the bounds of the PolyObject -
:moveXY(x, y [, checkmobjs]): special function that moves a PolyObject horizontally.xis the X distance to move,yis the Y distance to move,checkmobjsis a boolean to enable/disable physics with mobjs (enabled by default) -
:rotate(delta [, turnthings [, checkmobjs]]): special function that rotates a PolyObject.deltais the angle to rotate,turnthingsis an int32 to determine if and which mobjs should be rotated with it (0 = nothing, 1 = turn only non-players, 2 = turn everything),checkmobjsis a boolean to enable/disable physics with mobjs (enabled by default)
The last five can also be written longhand, e.g. polyobj.pointInside(polyobj, x, y), but obviously it's much simpler to omit the first arg, hence why I've given them with : as in polyobj.pointInside(x, y).
Of the others, only .parent, .flags, .translucency can be modified currently.
POF_ flags descriptions (from source code):
POF_CLIPLINES = 0x1, ///< Test against lines for collision
POF_CLIPPLANES = 0x2, ///< Test against tops and bottoms for collision
POF_SOLID = 0x3, ///< Clips things.
POF_TESTHEIGHT = 0x4, ///< Test line collision with heights
POF_RENDERSIDES = 0x8, ///< Renders the sides.
POF_RENDERTOP = 0x10, ///< Renders the top.
POF_RENDERBOTTOM = 0x20, ///< Renders the bottom.
POF_RENDERPLANES = 0x30, ///< Renders top and bottom.
POF_RENDERALL = 0x38, ///< Renders everything.
POF_INVERT = 0x40, ///< Inverts collision (like a cage).
POF_INVERTPLANES = 0x80, ///< Render inside planes.
POF_INVERTPLANESONLY = 0x100, ///< Only render inside planes.
POF_PUSHABLESTOP = 0x200, ///< Pushables will stop movement.
POF_LDEXEC = 0x400, ///< This PO triggers a linedef executor.
POF_ONESIDE = 0x800, ///< Only use the first side of the linedef.
POF_NOSPECIALS = 0x1000, ///< Don't apply sector specials.
POF_SPLAT = 0x2000, ///< Use splat flat renderer (treat cyan pixels as invisible).
Other features:
-
PolyObjects[]is now accessible to Lua. This is an array storing all the PolyObjects in the map.#PolyObjectsgives the total number of them. -
PolyObjects.iterateiterates through all PolyObjects in the map. This functions like most of our other.iteratefunctions already in SRB2. -
PolyObjects.GetForNum(id)converts a PolyObject ID (the one used in the map) to the actualpolyobj_tit is associated with -
line.polyobjif aline_tbelongs to a PolyObject, this will give thepolyobj_tof it -
searchBlockmaphas a new"polyobjs"search option! This functions like the"objects"and"lines"options, except this deals withpolyobj_tinstead obviously. -
subsector.polyList()is a special function for iterating through all PolyObjects in the subsector. This functions much likesector.thinglistorsector.ffloorswhich already exist
(did I forget anything above? literally have to be off now as I'm writing this)
(sphere edit: closes #19 (closed))
Edited by sphere