[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]
 
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:
ok thanks...
i just wanted to be sure the function could accept a change on the + sign
 
Status
Not open for further replies.
Back
Top