Quote:
Originally Posted by Element of Water
different people have different opinions on "bad style"
|
Still there are some conventions.
Quote:
Originally Posted by Element of Water
It's not at all. Constants are there to make it easy to change elements of the script. The game can't detect more than the 4 arrow keys anyway, so what's the point in making it changeable in my script when it won't actually do anything?
|
Have you ever heard the words "maintainability" and "readability"?
I bet an advanced programmer ( like you ) has, so you should be able to answer your question all on your own.
It is still changeable in your code. I could just go arround and change all your fours to threes, for example.
Constants are there to easily modify your code and to make it more readable. According to your argumentation: Why on earth would somebody name a constant Pi, if he can just aswell write 3.1415926..... ? It is not meant to change anyway!
local integer angle = 0
local unit trigUnit = GetTriggerUnit()
loop
exitwhen angle > 3.1415962
call SetUnitX( trigUnit, 10 * Cos( angle ) )
call SetUnitY( trigUnit, 10 * Sin( angle ) )
set angle = angle + 0.31415962
endloop
VS
local integer angle = 0
local unit trigUnit = GetTriggerUnit()
loop
exitwhen angle > PI
call SetUnitX( trigUnit, RADIUS * Cos( angle ) )
call SetUnitY( trigUnit, RADIUS * Sin( angle ) )
set angle = angle + PI/10
endloop
So, what is the point of making 3.1415926 a constant PI, that is changeable with a few clicks?
PS:Yourspacingisquite wierd.
set KeyDown[MAX_NUMBER_OF_PLAYERS*1+GetPlayerId(GetTriggerPlayer())] = false