Triggering terminals on a polygon

Questions about the content creation procedure go here, including using Forge, Anvil, or other editors, or operating emulators like Basilisk II.
Post Reply
User avatar
WeirdoYYY
Born on Board
Posts: 69
Joined: Feb 12th '13, 16:59
Location: Mars

Long time no post... I'm sort of jumping back into the project I was working on and looking to find a work around or some guidance on how I would pull off triggering a terminal on a polygon.

I have the idea to use an animated scenery item like a navigation point thing as the setting of my scenario I feel wouldn't be as immersive if it was only through computer terminals. The idea basically is you would see these floating icons and press the action key or step onto / into them to trigger a terminal.

I know one work around would be to make a regular terminal and then hide it with a wall texture covering that line with the icon sort of floating near it. The problem is that you'd have to be facing the wall of course for it to work.

There doesn't seem to be anything in the triggers section of the Lua Scripter's Guide but I also don't know enough about Lua so maybe I'm reading this wrong. Any help to point me in the right direction or to figure this out would be greatly appreciated.
"He looked at his hands, but the fire in his eyes made him blink."
User avatar
Wrkncacnter
Vidmaster
Posts: 1953
Joined: Jan 29th '06, 03:51
Contact:

What you want is find_target and activate_terminal in the lua docs. If the player is looking at whatever scenery object, is within a certain distance, and hits action, you can activate whatever terminal you want.

You don't even need find_target if you want to just step into them to activate.
User avatar
WeirdoYYY
Born on Board
Posts: 69
Joined: Feb 12th '13, 16:59
Location: Mars

Wrkncacnter wrote:What you want is find_target and activate_terminal in the lua docs. If the player is looking at whatever scenery object, is within a certain distance, and hits action, you can activate whatever terminal you want.

You don't even need find_target if you want to just step into them to activate.
Right, I guess I should specify that I want to have multiple terminals be triggered in this way so it won't be one scenery object triggering the same one which makes a polygon a better option. I have never made a Lua script before but this seems straight forward enough for me to try and learn how to use it.

So I would call Triggers.init and have it set so that if player is in Polygons[whatever].area, Players[0].activate_terminal ?
"He looked at his hands, but the fire in his eyes made him blink."
User avatar
The Man
Vidmaster
Posts: 1203
Joined: Aug 6th '08, 05:23
Location: Sarasota, FL
Contact:

I’m not sure I fully understand what you’re trying to do, but in any case, you definitely don’t want to place your code in Triggers.init(), which only executes when the level is first loaded (whether from a previous level, a new game, or a save file). And you don’t need to call Triggers.init(), per se; it executes automatically. The same is true for Triggers.idle(), which is where you actually want to place the relevant code.* Triggers.idle() automatically executes once every game frame after the level loads, until such time as a player leaves the level.

*Although you can also write a subroutine for it and have Triggers.idle() call the subroutine, which I frequently do if a game function gets convoluted enough. (And honestly, even more of the code in that link could and probably should be moved off to subroutines… and oof, I need to fix some of that indentation.)
“People should not be afraid of their governments. Governments should be afraid of their people.” —V, V for Vendetta (Alan Moore)

“The trouble is that we have a bad habit, encouraged by pedants and sophisticates, of considering happiness as something rather stupid. Only pain is intellectual, only evil interesting. This is the treason of the artist: a refusal to admit the banality of evil and the terrible boredom of pain. If you can’t lick ’em, join ’em. If it hurts, repeat it. But to praise despair is to condemn delight, to embrace violence is to lose hold of everything else. We have almost lost hold; we can no longer describe happy man, nor make any celebration of joy.” —Ursula K. Le Guin, “The Ones Who Walk Away from Omelas”

“If others had not been foolish, we should be so.” —William Blake, The Marriage of Heaven and Hell

“The law cannot protect anyone unless it binds everyone; and it cannot bind anyone unless it protects everyone.” —Frank Wilhoit

Last.fm · Marathon Chronicles · Marathon Eternal 1.2 · Where Monsters Are in Dreams · YouTube Vidmaster’s Challenge
User avatar
Ku-rin
Born on Board
Posts: 59
Joined: Feb 15th '19, 15:14
Location: Not Invented Here

WeirdoYYY wrote: So I would call Triggers.init and have it set so that if player is in Polygons[whatever].area, Players[0].activate_terminal ?
You'll put an if statement inside of Triggers.idle, presumably something like "if Players[0].polygon == terminalPolygon" where terminalPolygon is Polygons[n], n being the index of the polygon in question. This will presumably :activate_terminal(whateverTerminal) when true. What may catch you up though is that while you are in the terminal, Triggers.idle will still run and do exactly as directed, activating the terminal over and over again as long as you are in the polygon. I forget if :activate_terminal checks for you, but I feel like it does not. If I am wrong, ignore this.

To avoid this (if it is so), remember to set some kind of boolean global flag variable whenever you enter a terminal, and clear it when you leave. For this, there are Triggers.terminal_enter and Triggers.terminal_exit. Add this variable to the condition of the if statement, perhaps looking like "if Players[0].polygon == terminalPolygon and Players[0]._notInATerminal".

I also vaguely recall there being issues with using action flags to invoke terminals, as the action flags are disabled in terminals. If you should wind up using action flags, and run into problems with this, try rigging a latch variable of some sort instead of directly if-ing the action flag.

Pore over the reference and look at other Lua scripts while tinkering. Eventually it should work. Good luck.
Post Reply