Getting the info of a specific object in Lua

Status
Not open for further replies.

amperbee

thunderdome denizen
Retired Staff
How do I refer to a specific object/player/enemy/whatever of a level in Lua?
I want to make a map with four rooms, each room having a dummy object at the center (a bush for example), so when I enter that room a function launches making enemies appear around the bush.
Basically I need to get the position of that dummy object but I don't know how.

EDIT: I want to get the XYZ coordinates of the bush so I can add a random number (from -3 to 3, for example) to every coordinate, setting the XYZ coordinates to spawn the enemy
 
Last edited:
There are various methods to get objects in specific map-defined locations. With dummy objects you have even more flexibility. Probably the cleanest way to do this is to grab mobj.spawnpoint.angle (this is the exact number put into the editor, unlike mobj.angle which is converted to angle_t) and use that as a tag, then grab the object in your script based on this value. If speed is a concern and you want to avoid unnecessary lookups, use a MapLoad hook that iterates through every object in the map and puts them in a reference table (for best results, just do referencetable[mobj.spawnpoint.angle] = mobj), then your script can simply use referencetable[tag] to get the object.

(Here's a tip in case you weren't aware: when using LD443, Execute Lua Function, you can get any attribute of the line from within the Lua callback. Use its tag, line.tag, to determine which reference table entry you grab, so you can use the same function and simply change the tag to determine where the objects spawn from.)
 
I'm not so experienced with Lua, so I didn't understand.
However, i'll try something based on what you told me.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top