Welcome to the Builder Academy

Question teleport trigger help

More
16 Sep 2017 18:22 #6904 by thomas
Replied by thomas on topic teleport trigger help
Hmm... well, it should work with just that script, with no loops. Strange...

Please Log in or Create an account to join the conversation.

More
16 Sep 2017 18:46 #6905 by JTP
Replied by JTP on topic teleport trigger help
Unfortunately it doesnt work, leaving the rest of the group in the room with No exist :(

Please Log in or Create an account to join the conversation.

More
17 Sep 2017 11:50 #6906 by Parnassus
Replied by Parnassus on topic teleport trigger help
Both Thomas and I have mentioned that ALL is not a valid target and that you need to loop to target everyone. Then you keep saying that since you're using all, you shouldn't need a loop but it isn't working. I think you may find that if you make a character named All (or even Allen) that it will work on him even if he isn't in the room. This would possibly work on a mob also. If you have error messages turned on, you'll probably have seen the game complain that it can't find anyone name All to teleport.

Please Log in or Create an account to join the conversation.

More
17 Sep 2017 21:08 #6907 by thomas
Replied by thomas on topic teleport trigger help

Jan wrote: Unfortunately it doesnt work, leaving the rest of the group in the room with No exist :(

Ahh - I misunderstood you.

So, what Parna states is correct - you will need to loop over the followers to make them follow their leader to the new room.

In pseudoscript, you'll need to do one of these things:
  • When anyone enters, regardless of whether they're the leader, add a timer to get them to move, or
  • When someone with followers is moved out, the followers are moved as well.
  • When anyone enters, they are marked to be teleported out later. A different trigger handles the eviction.

The first way is easy. As long as it's just a single character, it "just works" with %wait% and %teleport%. However, as long as we are running the script, we cannot trigger it again - even if we're currently in a wait state. This means you are actually only triggering on the first character to enter. Thus only the first character is getting teleported.

The second way is the way of the loop. However, having a group in a room for 60 seconds adds a lot of error sources - what if they ungroup while in the room? What if they fight, and the leader dies? This is the way of insanity - the checks will eventually outgrow the buffer size.

So, the third way presents itself. A simple trigger that just saves the entry time on the player.
Code:
eval time_to_leave %time.hour% + 1 if (%time_to_leave% == 24) set time_to_leave 0 end remote time_to_leave %actor.id%

And then another trigger, triggering the actual move (this can be an enter trigger as well):
Code:
while 1 wait 30 s eval target_char %self.people% while %target_char% * Set the next target before this one is moved set tmp_target %target_char.next_in_room% * actually check if _this_ guy needs a move... if (%time.hour% == %target_char.time_to_leave%) %teleport% %actor% 11990 %force% %actor% look end * Find next target set target_char %tmp_target% done done
This last trigger will, every 30 seconds, check if there are any characters with the given hour set as the time for departure.

The usual notes about this being browser code apply.

Please Log in or Create an account to join the conversation.

More
17 Sep 2017 21:26 #6908 by Parnassus
Replied by Parnassus on topic teleport trigger help
Thomas, I'm going to ask this, just because I'm easily confused. Somewhere that I was building, I found that doing an entry trigger didn't actually trigger everyone because following people arrive too fast. Does that affect TBA code? It seemed that, since everyone arrives seemingly at the same time, the trigger would be running for the first person and when it finished, it would hit the next available person who may or may not have been the second person to enter. Yes, I know the computer much works faster than my eyes :)

Please Log in or Create an account to join the conversation.

More
17 Sep 2017 21:43 #6909 by thomas
Replied by thomas on topic teleport trigger help
This usually happens because the script has a wait in it. Only one instance of the trigger can run. So the first enters, triggers the script. The script enters wait state. Now everyone else enters the room. The trigger does not fire, because it is already running.

This is true for every trigger type.

Please Log in or Create an account to join the conversation.

Time to create page: 0.259 seconds