• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] hum, i have a noob question

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi

[Jass=]
call SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta)
[/code]
in this function if the number delta is negative, should i write it like that
[Jass=]
call SetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_LUMBER) + -2)
[/code]
or like that (is it the same, or is there a way to deal with these function?)
[Jass=]
call SetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_LUMBER) - 2)
[/code]
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
would + - 2 compile?
Yeah, it would. You're right though: using "- 2" (without the +) is more readable :).

Basically it's the same thing.
After all, subtraction is nothing more than a negative addition.

Same goes for "Y / X". You might also write "Y * X-1", but you don't do that because the first one is more readable (you might on paper, but usually not in programming).
 
Last edited:

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
ok thanks...
i just wanted to be sure the function could accept a change on the + sign
 
Status
Not open for further replies.
Top