• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Changing sign of variable.

Status
Not open for further replies.
Level 2
Joined
Jan 23, 2020
Messages
3
I use this trigger currently to get a negative number taken from the player

  • Player - Add ((Integer(Iron_Ingot)) - (Integer((Iron_Ingot x 2.00)))) to (Owner of (Buying unit)).Current gold
I have tried using the below trigger, but that doesn't work.

  • Player - Add (Sign((Integer(Iron_Ingot)))) to (Owner of (Buying unit)).Current gold

I wanted to know if there's an easier way to change the sign of the variable "iron ingot"?
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
The Sign() function only returns -1 for negative number and 1 for positive number.
What you can do is simply multiply the value by -1 to make it negative.
  • Player - Add (-1 x value) to Player 1 (Red).Current gold
 
Level 2
Joined
Jan 23, 2020
Messages
3
The Sign() function only returns -1 for negative number and 1 for positive number.
What you can do is simply multiply the value by -1 to make it negative.
  • Player - Add (-1 x value) to Player 1 (Red).Current gold

Honestly, this makes a lot of sense and I hate my self for not thinking of this at first.

Thanks a bunch!
 
Status
Not open for further replies.
Top