Variable NOT working

MissKerrigan

Active Member
Reaction score
23
Hello there guys,

This is what I did:

- I created a variable of the type integer with an array of 10
- I set the array 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 in the map initialization
- When a player pickes up a treasure he gets a random mineral bonus between 10 to 100

- I used the same variable for the text tag which I created also in the triggers
- I did this with combine text and used the integer

Now here is my problem:

- When I pick up a treasure it shows +30 minerals but I got 50 minerals
- The next treasure shows me +80 minerals but I got only 40

Does anyone what's going on here please?

MissKerrigan
 

Dave312

Censored for your safe viewing
Reaction score
269
You need to post your trigger.

Also to get your random bonus amount, you would be better off using the Random Number function to get a random number between 1 and 10, and then multiplying that value by 10.
 

hopy

Active Member
Reaction score
64
You don't need an array for this at all. All you need is a normal integer variable.

Trigger:
  • Giving minerals
    • Events
    • Local Variables
    • Minerals = 0 <Integer>
    • Conditions
    • Actions
    • Variable - Set Minerals = ((Random integer between 1 and 10) * 10)
    • Player - Modify player (Triggering player) Minerals: Add Minerals
    • UI - Display ("You have gained: " + ((Text(Minerals)) + "!!!!")) for (All players) to Chat area


That's all actually.
((Text(minerals) is a convert integer to string action btw))

PS: Can check more triggers if you'd want. Can help you make them more efficient and smaller. :)
 

MissKerrigan

Active Member
Reaction score
23
- I don't wanna have a display but a text tag

- It's not for all players, just for the player who picks up the treasure

- How I create a random number between 1 and 10? I'm sure I need an integer for this?
 

Dave312

Censored for your safe viewing
Reaction score
269
- How I create a random number between 1 and 10? I'm sure I need an integer for this?
There is a function called Random Number (it is in the Math category). Just set the minimum value to 1 and maximum value to 10.
 

hopy

Active Member
Reaction score
64
- I don't wanna have a display but a text tag

- It's not for all players, just for the player who picks up the treasure

- How I create a random number between 1 and 10? I'm sure I need an integer for this?
You know you can edit my trigger example to your needs? =/ Not that difficult you know...
- I don't wanna have a display but a text tag
Change it to a text tag then?
- It's not for all players, just for the player who picks up the treasure
Change the (all players) it to (triggering player), or (owner of (triggering unit)) or whatever?

I need your trigger events and all to know how to change this... I can't just add a (triggering player) and expect it to work, since it'll only work depending on what event you used, which I don't know...
 

MissKerrigan

Active Member
Reaction score
23
I just don't know how to activate the trigger
Do I have to make a region arround the treasures (bonus)

If yes, so how do I make this region if the bonus apeears in a random area of the map...
 

X-maul

AKA: Demtrod
Reaction score
201
Make sure you have your treasure unit stored in a variable, and then you use this Event:
Code:
        Unit - Any Unit Enters a distance of 1.0 from YOUR UNIT VARIABLE


Also, please take the time, and read (and understand) this tutorial.
 

MissKerrigan

Active Member
Reaction score
23
thanks X-Maul but actually I made this, it should work am I right??

event: any unit enters region treasure random spawn
condition: unit type of unit is treasure
action: move region treasure move to triggering unit

(the treasure move region is a 2x2 region which activates a trigger when a unit enters it)

WHY this is NOT working??

MissKerrigan
 

X-maul

AKA: Demtrod
Reaction score
201
You're making it a little bit too complicated, to be honest.

I cant see your triggers, so I cant see why it wont work.
On the other hand, I would NEVER use a region if I want to have an event that tiggers when a unit comes within range of another unit.

The only reason I would do that, was if I had a special formed region I needed to move.
Back to topic, when you spawn the treasure unit, store it into a global variable of the type "Unit".
Then you create a trigger that is turned initially off, and set the event to
Code:
 Unit - Any Unit Enters a distance of 1.0 from YOUR UNIT VARIABLE
Put the actions you want for when the unit is picked up (remember to kill / remove the treasure unit on pickup).

Now go back to the spawn trigger, add an action that turns on the second trigger, wait 60 seconds, and turn the trigger off again, and remove the treasure unit.
 

MissKerrigan

Active Member
Reaction score
23
1. I never knew there would be such events, there are so many! (think I've seen 1% of the conditions right now)

2. The problem is that ONLY the 'playing units' may pickup the treasure, for example not the critters or the structures (the treasure might spawn close to a critter or a structure)

3. I can't follow your last 2 lines, do you mean I have to make 2 triggers which turns on/off each other?

4. Does a local variable means that you can store something in it from the beginning of the map and a global variable means that you use it in a trigger?
 

X-maul

AKA: Demtrod
Reaction score
201
1. I never knew there would be such events, there are so many! (think I've seen 1% of the conditions right now)
The method I learned it, was to assume that there was events for everything, and as I moved through the editor, I found out which one were missing.
2. The problem is that ONLY the 'playing units' may pickup the treasure, for example not the critters or the structures (the treasure might spawn close to a critter or a structure)
Then what do you need? You need to make it a condition that it's a player owned.
3. I can't follow your last 2 lines, do you mean I have to make 2 triggers which turns on/off each other?
The first trigger, that spawns the treasure unit, should turn on the trigger that activates when a unit comes near it. And after 60 seconds, the treasure unit should be removed and the trigger turned off again.
4. Does a local variable means that you can store something in it from the beginning of the map and a global variable means that you use it in a trigger?
VRLaz.png

Global Variable = The variable that can be accessed from ALL triggers in the map.
Local Variable = Can only be accessed in the trigger it has been created.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top