• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[JASS] What type of local is this??? Version?

Status
Not open for further replies.
Level 9
Joined
Oct 11, 2009
Messages
477
Hi... May I ask what is the purpose of this local variable 'version'. I discovered this variable when I try many times creating local variable with different types, and then when I entered a custom script line that reads "local version v". Unexpectedly the WC3 engine accepted the variable type 'version'. I think its the game version like 1.24d and 1.24e but I don't think that's it or I am lacking clarification about that.


Thanks for someone who will clarify this for me and of course +rep!!!:thumbs_up:
 
Specifically:

JASS:
function MeleeStartingResources takes nothing returns nothing
    local integer index
    local player  indexPlayer
    local version v
    local integer startingGold
    local integer startingLumber

    set v = VersionGet()
    if (v == VERSION_REIGN_OF_CHAOS) then
        set startingGold = bj_MELEE_STARTING_GOLD_V0
        set startingLumber = bj_MELEE_STARTING_LUMBER_V0
    else
        set startingGold = bj_MELEE_STARTING_GOLD_V1
        set startingLumber = bj_MELEE_STARTING_LUMBER_V1
    endif

    // Set each player's starting resources.
    set index = 0
    loop
        set indexPlayer = Player(index)
        if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
            call SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_GOLD, startingGold)
            call SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_LUMBER, startingLumber)
        endif

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
endfunction

JASS:
native VersionGet takes nothing returns version

Theres a constant for ROC and TFT, a function to convert an integer to a version (but no function to convert back), a function to compare the version you're running to a version variable, and a function for whether its supported (I guess that returns true for TFT only if youre running TFT, but returns true for ROC if youre running ROC or TFT).
 
I have to say I have never used this, ever, nor did I even know about it. But, there is something that hasn't been mentioned.

(but no function to convert back)

Not true. If you use GetHandleId(VERSION_FROZEN_THRONE) it will return 1 (just as ConvertVersion(1) will return VERSION_FROZEN_THRONE.

By the way, why is it that anything with bj_ is highlighted as a constant? Also notice that the "0" and "1" at the end of bj_MELEE_STARTING_GOLD_V0 is not highlighted despite being apart of the constant's name.

JASS:
bj_WHY
bj_CAN
bj_I
bj_MAKE
bj_MY
bj_OWN
bj_CONSTANTS?
 
Status
Not open for further replies.
Back
Top