• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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:
 
Level 10
Joined
Mar 31, 2009
Messages
732
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).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
Top