Making a Linedef Executor Trigger in Lua?

Status
Not open for further replies.
So... Linedef Type 443 allows us to use Lua functions when triggered by a Linedef Executor Trigger. But the vanilla Linedef Executor Triggers are sort of limited.

So, as a random example, is it possible, and what would be the easiest way, to check "if mobj.player and mobj.player.speed>25*FRACUNIT" for objects in a sector with tag 1, and if true, execute all Linedef Executors on the checking line's sector?
 
Just make your test inside the Lua function.
...That is an option. Thank you. But then how do I make sure said Lua function always runs when I want it? (Maybe I want it to account for something other than a player while it's not a pushable either, or perhaps even continously forever at all time?)
 
Here is how I would've dealt with your example:

Code:
addHook("LinedefExecute", function(line, mobj, sector)
    if mobj.player and mobj.player.speed > line.textureoffset
        local tag = line.rowoffset / FRACUNIT
        P_LinedefExecute(tag, mobj, sector)
    end
end, "TESTSPEED")
Call this function with a regular continuous/once linedef executor trigger, and create a separate sector which contains the actions you want to trigger if the condition is fulfilled.
The line's x-offset is the speed needed to fulfill the condition, the y-offset is the tag of the trigger linedef on the sector with the actions that need to be called.

---------- Post added at 01:21 PM ---------- Previous post was at 01:12 PM ----------

...That is an option. Thank you. But then how do I make sure said Lua function always runs when I want it? (Maybe I want it to account for something other than a player while it's not a pushable either, or perhaps even continously forever at all time?)
Oh sorry I didn't think you wanted to go this far.
Sadly if your mobj isn't a player neither a pushable, I'm almost certain you can't make it activate a trigger executor linedef, so you'll probably need to make an extra hook (most likely a ThinkFrame, or a MobjThinker, depending on your needs) that continuously checks if the mobj is still inside the sector, and if so calls a trigger linedef on the sector with all of your actions via P_LinedefExecute.
 
Last edited:
Here is how I would've dealt with your example: [Code and such]
Although I might want to go more extreme than checking just players/pushables, that does seem very useful for getting me started on Lua triggers. Thank you a lot.

And running a hook for all/specific objects to check if they're in a sector, and if so, running a linedef executor and such, does seem to be a lot of trouble considering multiple maps, custom maps, and stuff like that. However, you mentioning that did give me an idea I could potentially use if I ever want to go that extreme.
(Something about a custom invisible object with a MobjThinker hook which just continously executes a linedef tag corresponding to its own angle, and then that executes a Lua function which checks through all existent objects. Could work if done right, I guess.)
 
(Something about a custom invisible object with a MobjThinker hook which just continously executes a linedef tag corresponding to its own angle, and then that executes a Lua function which checks through all existent objects. Could work if done right, I guess.)
It could probably be done through a ThinkFrame hook plus a custom level header variable, so you can make it happens only on specific maps.
Something like:
Code:
Level 1
LevelName = Sample Map Zone
Act = 0
...
YourOwnCheck = 1234
In a SOC lump, and
Code:
addHook("ThinkFrame", function()
    if mapheaderinfo[gamemap].yourowncheck ~= nil
        -- Do your stuff
    end
end)
In a Lua lump. The 1234 would be the tag of the trigger executor linedef that should be called.
 
It could probably be done through a ThinkFrame hook plus a custom level header variable, so you can make it happens only on specific maps.
Yes... The problem with that, though... What if someone uses another Wad to replace the map, without altering the level header? Besides that, it would probably be better performance-wise to use that object method I mentioned, especially for maps without stuff to execute like that, and also allow me to execute multiple linedefs (by using multiple objects) without having to make Lua scripts longer and such. (Also, I think you have to use "Lua.variable" instead of just "variable" in level headers for custom variables.) Still, though, I really appreciate your willingness to help and such.
 
Last edited:
(Also, I think you have to use "Lua.variable" instead of just "variable" in level headers for custom variables.)
Oh yes, my bad.

Anyway, I guess it mainly depends on what exactly you are trying to do (or will be trying to do).
 
Last edited:
Status
Not open for further replies.

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

Back
Top