Verifying Variable Un-Nullity

Centreri

New Member
Reaction score
1
Well, I didn't really know how else to word it.

I'm making a system slightly different from Baka-Rangers for the Custom Hero stuff, and instead of his inventory loop, I'm trying to implement a loop that checks if the variable storing the abilities has slot 1, 2, etc for each player has an ability there or if it has no value. I've checked Boolean comparison and it doesn't seem have have anything like that, and I have about no idea where else it could be. Thank you in advance.
 

SFilip

Gone but not forgotten
Reaction score
634
If I understood correctly, what you need is Item Comparison:
(Item carried by <your unit> in slot 1) Equal to No item
 

Centreri

New Member
Reaction score
1
No. I have a variable for 10 players with 50 ability slots. Every five are for a certain player - first four are regular, last is ultimate. I plan it so that every time a player buys an ability, it records it in this variable ((player # - 1) x 5 + (1+( abilities already chosen))). In order for it to not overwrite previous variable entries, I need to check in a loop which slots of the variable are taken, which is what I can't find how to do - check if a variable is filled or not filled.
 

Tom Jones

N/A
Reaction score
437
How about:
Code:
For each (Integer A) from 1 to 5, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                *YourVariable*[(Integer A)] Equal to 0
            Then - Actions
                *Set the variable here, use Integer A as index*
                Custom script:   exitwhen true
            Else - Actions
 

Centreri

New Member
Reaction score
1
It's an ability variable. I can't set it to a number. I just need something that will replace 'Ability X equal to no ability', or 'Variable x is empty'. Something like that.

Ah.. is the custom script a loop-breaker? I had asked for something like that before, didn't get an answer. Thanks for that.
 

Tom Jones

N/A
Reaction score
437
It's an ability variable. I can't set it to a number. I just need something that will replace 'Ability X equal to no ability', or 'Variable x is empty'. Something like that.
How about jass? You could still use the ability variable alongside another variable to keep track of the abilities. Using null in a comparison between abilities is impossible in GUI as far as I remember.
 

Centreri

New Member
Reaction score
1
Now, that's stupid.

I suppose I can assign every ability a number... but I really really don't want to have to go through that trouble. And I don't know JASS, so that wouldn't be a great option.

Well, if no one else knows, I'll have to do this the hard way.
 

SFilip

Gone but not forgotten
Reaction score
634
You'll have to use some custom script
Custom Script: if (udg_somevariable == 0) then
// the variable is empty, your actions go here
Custom Script: endif

udg_ is a requires prefix for global variables in Jass. So, if your variable is named abc in GUI then you should use udg_abc here.
 

Centreri

New Member
Reaction score
1
Hmm. I know 0 JASS, so how would I stick this variable in that:
HeroAbilities[(((Player number of triggering player)-1)x5)+ Integer A)?
 

SFilip

Gone but not forgotten
Reaction score
634
udg_HeroAbilities[(GetPlayerId(GetTriggerPlayer())*5)+bj_forLoopAIndex]
So the whole thing would be:
Custom Script: if (udg_HeroAbilities[(GetPlayerId(GetTriggerPlayer())*5)+bj_forLoopAIndex] == 0) then

You probably noticed that I left -1 out. In Jass, player Ids begin with 0 (as opposed to 1 in GUI) so it's not needed.
 

Centreri

New Member
Reaction score
1
Thanks. Trying it out now.

At first didn't copy the then but got errors, but the trigger debugger here is amazingly competent. Thanks a lot, SFilip.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top