Author Topic: Multiple running script  (Read 690 times)

0 Members and 1 Guest are viewing this topic.

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Multiple running script
« on: January 25, 2018, 10:04:18 PM »
Let trigger_multiply call a script which begin some actions with some entity.

What happen if the player still stand in trigger zone?
Is this script will be started again?
But if entity is already in action? Is script must set some flag and prevent multiply instances?

Is there a native flags/commands like "isTriggered" etc?

Thanks.

Snehk

  • Newbie
  • *
  • Posts: 49
  • Karma: +6/-0
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #1 on: January 26, 2018, 02:48:29 AM »
I think that trigger_multiple won't trigger again until player leaves it and then walks on/touches it again. I might be wrong though, and in such case it would re-trigger after the set delay is over.

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #2 on: January 26, 2018, 06:11:43 AM »
Thanks, Snehk

I make a script with one line

Code: [Select]
sys.println( "trigger" );
If player standing in trigger zone this message send to console at intervals approx. one second.

There is a "wait" k/v for trigger and it can give behavior which you describe above.

So, must be other solution.



bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #3 on: January 28, 2018, 08:56:01 AM »
It's works fine with trigger_once but only one time.

Don't know how to reset trigger_once.

motorsep

  • Hero Member
  • *****
  • Posts: 1,002
  • Karma: +74/-131
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Multiple running script
« Reply #4 on: January 28, 2018, 09:05:13 PM »
trigger_multiple triggers several things all at once

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 904
  • Karma: +43/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Multiple running script
« Reply #5 on: January 29, 2018, 01:08:58 PM »
def file also says it is a repeatable trigger.  trigger_multiple & once both are the same spawnclass & the def for trigger_once defaults a wait of "-1" which means only trigger once.  So it's just a def that defaults to triggering once but can be used multiple times.

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #6 on: February 05, 2018, 08:16:00 AM »
Thanks!

Now I'm going deeper and trying to use trigger_multiple which running once and then retriggered via script.

Related question - can I set any custom spawnArgs in entity on the map (and use it in script via 'getKey') or they are predefined? Is there any restrictions?

Thanks!
« Last Edit: February 05, 2018, 08:18:00 AM by bitterman »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 904
  • Karma: +43/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Multiple running script
« Reply #7 on: February 05, 2018, 01:11:28 PM »
You can set any spawnargs you want to the entity & only the recognizable ones will be used by the game.  So, if you have a trigger with the spawnarg "stupid 1" & used "getkey" on "stupid" it should result in 1. 

I haven't tested this in a while but I want to say I've done it before to store values in entities.

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #8 on: February 05, 2018, 09:15:09 PM »
Good naming, thanks ;)

********* upd

I'm look at Trigger.cpp and looks like trigger just removed if 'wait' <= 0 or reset after waiting if 'wait' > 0 (0.5 by default).

I don't see any other way to control trigger's reset. It works like 'pew-pew-pew' ))

« Last Edit: February 06, 2018, 07:52:39 AM by bitterman »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 904
  • Karma: +43/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Multiple running script
« Reply #9 on: February 06, 2018, 01:35:27 PM »
Well, normally triggers activate something, use a script that every X seconds checks for a condition & when the condition is met, activate whatever the trigger would.  If you want multiple things activated at once have the script call a trigger_relay.

Should work.

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #10 on: February 06, 2018, 09:19:46 PM »
This is what I trying to achieve:

When the player step into trigger zone around an interactive object this trigger shows a label on the top of this object (ent.show()).

This part works fine for me.

Then player goes out of trigger zone (ent.hide()). This is works too.

But then player back into trigger zone. Here is the problem: if it trigger_once then it already removed after fired.
If it trigger_multiple then label will blink when player stay still into zone.

In fact I trying to get inactivate triggger and retrigger it at the end of script (if player leave trigger zone then retrigger for next case).

Sorry for wall of text )
« Last Edit: February 06, 2018, 09:25:55 PM by bitterman »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 904
  • Karma: +43/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Multiple running script
« Reply #11 on: February 06, 2018, 09:54:26 PM »
instead of a trigger you could use a check in a script to check player distance to a location.  If/then to decide how to handle it.

Or have a check to see if the object is already showing, maybe with storing a key/val in the player entity.  If showing then it skips most of the script again (again, if/then statement).

bitterman

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Multiple running script
« Reply #12 on: February 07, 2018, 06:51:27 AM »
Then it should be like:
Code: [Select]
alreadyShown = label.getKey("alreadyShown");
...
if (!alreadyShown) { label.show(); }

Looks nice.

************** upd

There is a native flag:
Code: [Select]
if ( isHidden ) { label.show( ); }
« Last Edit: February 08, 2018, 07:17:37 AM by bitterman »