[General] two jass questions

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,289
1. I have seen a few scripts using private nad public stuff is that a big deal? example why use private integer i insted of integer i. also public integer must be the most pointless line ever since it's allready global no need to make it public? (if it aint a local variable ofc)

I know that a private only works within the block but when is that something importment?

2. can i set loop speed into jass? Id want something like
JASS:
loop 1.00
exitwhen i = 10
set i = i +1
endloop

that would be supposed to loop every second (1.00) is there something like that in jass or do I need to use a loop event for that?
 
I know that a private only works within the block but when is that something importment?

You might not want to allow users to modify values outside of the library/scope/struct. For example you might have a projectile flying, and it has speed variable. You might not want to people to meddle with the speed so you set it to private.

2. can i set loop speed into jass?
Use a timer.
 
About making variables private, it's more for preventing name collisions. A variable named speed is likely to be declared by multiple resources so instead of wasting time thinking of a new name, you make it system's private.
Public variables have scope prefix that also prevents name collisions and makes the variable identifier unique yet usable outside of scope.
 
Status
Not open for further replies.
Back
Top