Item moving back to priginal place

Psycho-Noob

New Member
Reaction score
0
So i have a trigger here:
Trigger:
  • Key Placement
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Place Key
    • Actions
      • Item - Create Gate Key at (Position of (Triggering unit))
      • Set KeyItem[KeyInt] = (Last created item)
      • Set Keytemppos[KeyInt] = (Position of (Last created item))
      • Set KeyInt = (KeyInt + 1)


That sets a item created to a item variable and position variable so that: KeyItem[0] would link with Keytemppos[0](hopefully), if that does not work could you please tell me why because i'm still fairly new to mapping : (.(also i should not on map initialisation i set keyint to 0. (keyint is an integer....just to clarify).

I have triggers that after certain events move the key/s to a certain region.
What i want to happen is when a unit enters a certain region, the keys in the region mentioned above will go back to their original places.
Here is my attempt:
Trigger:
  • Key Respawn
    • Events
      • Unit - A unit enters Keyreset1 <gen>
      • Unit - A unit enters Keyreset2 <gen>
      • Unit - A unit enters Keyreset3 <gen>
      • Unit - A unit enters Keyreset4 <gen>
    • Conditions
    • Actions
      • Item - Pick every item in KeyRespawn <gen> and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 100, do (Actions)
            • Loop - Actions
              • Item - Move KeyItem[(Integer A)] to (Keytemppos[(Integer A)] offset by 0.00 towards 0.00 degrees)

And of course it is not working : (.
I'm not sure what is wrong.
Thanks in advance.

)
 

Smitty

Member
Reaction score
20
Ok, a few things which may just help clear up your triggers slightly;

1. It's not necessary to set KeyInt to 0 manually. Just go into the variable editor thingy and it'll let you set an initial value (should be 0 by default anyway)

2. Set KeyTempPos as position of triggering unit, it saves you a line and also means you can avoid a memory leak.

3. You don't need to use 'point with offset' in your second trigger, just use the point variable.

4. How many keys do you had at once? If it's less than 100 save a small amount of CPU by only running it that many times. Also, change it to run every integer from 0-100, else use another integer variable which is (Integer A)-1, otherwise you're missing index [0] of your arrays. That may be why it's not working (if you've only tried it with one key).

Sorry I couldn't spot the problem for sure, but hope this helps :)
Good luck ^.^
 

Psycho-Noob

New Member
Reaction score
0
Ah yes, thanks for your input i totally spaced the [0] array in the 1-100 loop maybe that will fix it :D i dun derped.
The map is heavily based on user creation so i doubt there will be 100 keys, most probably 10 max, but i just put some spare perhaps i should lower the amount.

Thanks again

EDIT: Solved, i changed the loops to start from 0 instead of 1 so 0-25 (changed max) and it worked, because i never tested past making 1 key. :D
 

NotInTheFace

Member
Reaction score
17
You ought to just loop from 0 to KeyInt-1 :)
That will get all the keys without worrying about a hardcoded maximum.
 

Smitty

Member
Reaction score
20
Very true. I actually did a pretty much identical thing a couple of days ago, the thread is here somewhere if it would help. I looped to a variable number as well, allows for more situations as well as being more efficient.
 
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