Infinite loop?

ShinyPickle

New Member
Reaction score
9
I think there is an infinite loop in my trigger, but I don't know where. It's actually a series of triggers that were working fine last night, and I don't think I changed them. Here are the triggers.

Trigger1
Event: Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match

Action: Set Integer = (Integer((Entered chat string)))
That sets the integer to whatever number the player types. That was working.


Trigger2
Event: Time - Every 0.50 seconds of game time

Condition: Integer Greater than (Level of (Random unit from (Units in Region <gen>)))

Action: Trigger - Run Trigger3 <gen> (checking conditions)

If the number you typed in trigger1 is higher then the level of the unit currently in the region, it runs this trigger.

Action: If (Integer Equal to 1) then do (Unit - Remove (Random unit from (Units in Region <gen>)) from the game) else do (Do nothing)

Action: If (Integer Equal to 1) then do (Unit - Create 1 Unitl level 1 for Player 1 (Red) at (Center of Region <gen>) facing (Position of Barracks 0000 <gen>)) else do (Do nothing)

It was working fine last night... I wanted it to be so that when a specific event happens (Like the player typing the number, which was just to test it) it would change the value of the integer accordingly, thus placing the correct unit in the region. I had the same action in trigger3 5 times. One for each level. But when I test it, it creates infinite units one after another until I quit the game.
 

Exide

I am amazingly focused right now!
Reaction score
448
Um..
What the heck are these triggers? :p

-Why are you suspecting an infinite loop in one (or all) of these triggers?
-What happens?
-What is supposed to happen?
 

ShinyPickle

New Member
Reaction score
9
Um..
What the heck are these triggers? :p

-Why are you suspecting an infinite loop in one (or all) of these triggers?
-What happens?
-What is supposed to happen?

When I test the map, it keeps creating units in the same region one after another when I only want it to create one.
 

the Lumpy

►►►
Reaction score
53
Well, as long as the condition in Trigger 2 is true, Trigger 3 will run every .5 seconds. Keep in mind that the condition will only work as expected as long as there's only one unit in the region at a time.

As a last resort, you could set Integer to 0 after you create the unit -- that should stop the trigger from being run repeatedly.
 

ShinyPickle

New Member
Reaction score
9
But it only does it as long as the Intger is higher then the level of the unit... Maybe I screwed up and deleted an action from the trigger by mistake... I'll check that out.
 

cowmenace

New Member
Reaction score
22
Try this

In your second trigger, create a dummy for the player you want. set the dummy's custom value to 50. Make a .1 second expiration timer on the dummy.
In your third trigger, have the event be (Unit - A unit dies) and the condition be (Integer Comparison - Custom value of (Dying Unit) equal to 50)

that will also allow for the trigger to be MUI.

NOTE: your trigger leaks and since it is every .5 seconds you should make it leakless. http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=27219
read that it will make your game much less laggy


If that doesn't work, then try turning off the third trigger as the last action in it.
 

the Lumpy

►►►
Reaction score
53
The best way you can help us help you is by explaining what you intend to use this for in as much detail as possible.

I recall you said that you were just using the chat message event for testing. It looks like you want the unit to be updated automatically whenever the variable changes. If this is the case, you might consider making your variable a real instead of an integer -- you would have to do a lot of conversions between real and integer types, but it would allow you to use the Game - Value Of Real Variable event.
 

cowmenace

New Member
Reaction score
22
Shinypickle -
I got the trigger finished, but the viruses are unable to have the ability locust, so I included another trigger that prevents a player from moving the unit at all. I also took the liberty in removing leaks and a bug that I found (typing in a number like 123 would spawn a million question marks) Be sure to read my trigger comments for tweaking things the way you want. You have private messages disabled so I put my message here =). Anyway give me an email at [email protected] and I'll send it over to you, or give me permission to post it in this thread and I will.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top