• 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.

[General] two jass questions

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
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?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
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.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
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.
Top