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!
I have one script written in zinc that detects when a player dies. And the other written in jass that updates the multiboard. How can I create a boolean that changes when a player dies and have the jass script check if the boolean = true or false and run code?
I think I tried it in the jass script, I created a private global and tried to access it in the zinc script and it said variable undefined. I'm still a little fuzzy on what private means, does that mean it's confined to only the one script?
Well, if you were to solely use ZINC in your entire map, then making a function or variable private means they can only be accessed within the library they were declared.
If you mix JASS with Zinc, you can still access the Zinc private functions and variables, however they get a HUGE name, and their prefix is randomly generated.
I guess there's no problem declaring the variable in JASS, and using it in ZINC snippets, that way you have more control over them. Otherwise, you'll need to check the war3map.j (by intentionally inserting gibberish into the map script, and forcing the editor to throw an error), and see how the variable has been defined.
EDIT: Example
JASS:
//! zinc
library PlayerStatus
{
public boolean playerDead[12];
function PlayerStatusDeath() -> boolean
{
playerDead[GetPlayerId(GetTriggerPlayer())] = true;
return true;
}
function onInit()
{
integer i = 0;
trigger t = CreateTrigger();
TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH);
TriggerAddCondition(t, Condition(function PlayerStatusDeath));
for(0 <= i <= 11)
{
playerDead[i] = false;
}
}
}
//! endzinc
and then
If you remove the "public" keyword when declaring the variable, it becomes private by default, and its name size increases.
EDIT 2: Apparently, I forgot to mention that I got that "s__" prefix by declaring a sized array. public boolean playerDead[12];
Declaring it normally public boolean playerDead[]; does not add that "s__". So take into account what IcemanBo said below.
I think I tried it in the jass script, I created a private global and tried to access it in the zinc script and it said variable undefined. I'm still a little fuzzy on what private means, does that mean it's confined to only the one script?
in my zinc script, it's inside a function. It errors saying isDead is not declared. I'm not sure what's wrong?
Do I need to do library requires (script the jass is in) ?
"Public" can only be used inside a scope or library and requires you to name the code scope of definition of the variable. For example if it's in library A, then:
JASS:
library A
globals
public boolean isDead = false
endglobals
endlibrary
you would need to reference it with A_isDead. Private means you can not reference it from outside, and without any access prefix, so only boolean isDead = false, then you would not need the library's name at front, and could simply use it like you already do.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.