[Solved] Converting from GUI

Status
Not open for further replies.
Level 7
Joined
Aug 15, 2012
Messages
318
Hello I just started redoing all my gui and converting it into vjass/jass which ever I can use to make it most efficient at the time is what I will use. But in reality I will prob be posting multiple triggers on here eventually but we will start with map initialization because its confusing me atm I did read deathismyfriend's tutorial and I learnt a lot however there are some things it didn't cover that I have and I cannot find natives for the few that I have if anyone can give me some help would be just chipper thanks :).

JASS:
function Trig_Initialization_Func002Func001C takes nothing returns boolean
    if ( not ( GetPlayerSlotState(Player(GetForLoopIndexA())) == PLAYER_SLOT_STATE_PLAYING ) ) then
        return false
    endif
    return true
endfunction

function Trig_Initialization_Actions takes nothing returns nothing
    set udg_CreepTable = InitHashtable()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_Initialization_Func002Func001C() ) then
            set udg_TempLoc1 = GetStartLocationLoc(ConvertedPlayer(GetForLoopIndexA()))
                call CreateNUnitsAtLoc( 1, 'e000', ConvertedPlayer(GetForLoopIndexA()), udg_TempLoc1, bj_UNIT_FACING )
                call AdjustPlayerStateBJ( 1, ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_HERO_TOKENS )
                call AdjustPlayerStateBJ( 10, ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_FOOD_CAP_CEILING )
                call AdjustPlayerStateBJ( 450, ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_GOLD )
                call AdjustPlayerStateBJ( 75, ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_LUMBER )
                call SelectUnitForPlayerSingle( gg_unit_n016_0068, ConvertedPlayer(GetForLoopIndexA()) )
            call RemoveLocation(udg_TempLoc1)
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    // Initialize Systems
    call TriggerExecute( gg_trg_NPS_Initialization )
    call TriggerExecute( gg_trg_Load_Items )
    call TriggerExecute( gg_trg_Order_Test )
    call TriggerExecute( gg_trg_Icons )
    call TriggerExecute( gg_trg_Indestructable_Doors )
    call ConditionalTriggerExecute( gg_trg_Meet_the_King_Quest )
    call ConditionalTriggerExecute( gg_trg_Setting )
    call ConditionalTriggerExecute( gg_trg_Declaration )
    call FogEnable(false)
    call FogMaskEnable(false)
endfunction

//===========================================================================
function InitTrig_Initialization takes nothing returns nothing
    set gg_trg_Initialization = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Initialization, function Trig_Initialization_Actions )
endfunction
I know integer A is not good to use but I would like to try and replace it with a regular integer if anyone would like to help me what you see here may also not be what I have I am slowly changing things that I find solutions for.
 
Last edited:
Level 15
Joined
Oct 29, 2012
Messages
1,474
There you go (Pay attention to comment lines)

  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CreepTable = (Last created hashtable)
      • -------- Here I replaced 'Integer A' with a custom integer variable. (Create one before using it) --------
      • For each (Integer ForLoopInteger_Replacable) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(ForLoopInteger_Replacable)) slot status) Equal to Is playing
            • Then - Actions
              • Set TempLoc1 = ((Player(ForLoopInteger_Replacable)) start location)
              • -------- I don't really know what the ID of unit "e000" stands for. And I don't think this will work, all you have to do is check which unit has this ID. --------
              • Unit - Create 1 (Unit-type(e000)) for (Player(ForLoopInteger_Replacable)) at TempLoc1 facing Default building facing degrees
              • Player - Add (Player(ForLoopInteger_Replacable)) Available free Heroes to 1
              • Player - Add (Player(ForLoopInteger_Replacable)) Food cap to 10
              • Player - Add (Player(ForLoopInteger_Replacable)) Current gold to 450
              • Player - Add (Player(ForLoopInteger_Replacable)) Current lumber to 75
              • -------- This "gg_unit_n016_0068" was in JASS, and there is no way to put in GUI so all you have to do is search for this unit on the terrain --------
              • Selection - Select "gg_unit_n016_0068" for (Player(ForLoopInteger_Replacable))
              • Custom script: call RemoveLocation(udg_TempLoc1)
            • Else - Actions
      • -------- Initializing Systems ||| PAY ATTENTION TO 'ignoring' and 'checking' conditions --------
      • Trigger - Run NPS Initialization <gen> (ignoring conditions)
      • Trigger - Run Load Items <gen> (ignoring conditions)
      • Trigger - Run Order Tests <gen> (ignoring conditions)
      • Trigger - Run Icons <gen> (ignoring conditions)
      • Trigger - Run Indestructible Doors <gen> (ignoring conditions)
      • Trigger - Run Meet the king quest <gen> (checking conditions)
      • Trigger - Run Setting <gen> (checking conditions)
      • Trigger - Run Declaration <gen> (checking conditions)
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
 
Level 7
Joined
Aug 15, 2012
Messages
318
There you go (Pay attention to comment lines)

  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CreepTable = (Last created hashtable)
      • -------- Here I replaced 'Integer A' with a custom integer variable. (Create one before using it) --------
      • For each (Integer ForLoopInteger_Replacable) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(ForLoopInteger_Replacable)) slot status) Equal to Is playing
            • Then - Actions
              • Set TempLoc1 = ((Player(ForLoopInteger_Replacable)) start location)
              • -------- I don't really know what the ID of unit "e000" stands for. And I don't think this will work, all you have to do is check which unit has this ID. --------
              • Unit - Create 1 (Unit-type(e000)) for (Player(ForLoopInteger_Replacable)) at TempLoc1 facing Default building facing degrees
              • Player - Set (Player(ForLoopInteger_Replacable)) Available free Heroes to 1
              • Player - Set (Player(ForLoopInteger_Replacable)) Food cap to 10
              • Player - Set (Player(ForLoopInteger_Replacable)) Current gold to 450
              • Player - Set (Player(ForLoopInteger_Replacable)) Current lumber to 75
              • -------- This "gg_unit_n016_0068" was in JASS, and there is no way to put in GUI so all you have to do is search for this unit on the terrain --------
              • Selection - Select "gg_unit_n016_0068" for (Player(ForLoopInteger_Replacable))
              • Custom script: call RemoveLocation(udg_TempLoc1)
            • Else - Actions
      • -------- Initializing Systems --------
      • Trigger - Run NPS Initialization <gen> (ignoring conditions)
      • Trigger - Run Load Items <gen> (ignoring conditions)
      • Trigger - Run Order Tests <gen> (ignoring conditions)
      • Trigger - Run Icons <gen> (ignoring conditions)
      • Trigger - Run Indestructible Doors <gen> (ignoring conditions)
      • Trigger - Run Meet the king quest <gen> (checking conditions)
      • Trigger - Run Setting <gen> (checking conditions)
      • Trigger - Run Declaration <gen> (checking conditions)
      • Visibility - Disable fog of war
      • Visibility - Disable black mask

Thank you although I was hoping to keep it as jass trying to make all my systems etc in my maps vjass/jass.

JASS:
function Trig_Initialization_Func002Func001C takes nothing returns boolean
    if ( not ( GetPlayerSlotState(Player(udg_IIV)) == PLAYER_SLOT_STATE_PLAYING ) ) then
        return false
    endif
    return true
endfunction

function Trig_Initialization_Actions takes nothing returns nothing
    set udg_CreepTable = InitHashtable()
    set udg_IIV = 1
    loop
        exitwhen udg_IIV > 10
        if ( Trig_Initialization_Func002Func001C() ) then
            set udg_TempLoc1 = GetStartLocationLoc(Player(udg_IIV))
            call CreateNUnitsAtLoc( 1, 'e000', CPlayer(udg_IIV), udg_TempLoc1, bj_UNIT_FACING )
            call AdjustPlayerStateBJ( 1, Player(udg_IIV), PLAYER_STATE_RESOURCE_HERO_TOKENS )
            call AdjustPlayerStateBJ( 10, Player(udg_IIV), PLAYER_STATE_FOOD_CAP_CEILING )
            call AdjustPlayerStateBJ( 450, Player(udg_IIV), PLAYER_STATE_RESOURCE_GOLD )
            call AdjustPlayerStateBJ( 75, Player(udg_IIV), PLAYER_STATE_RESOURCE_LUMBER )
            call RemoveLocation(udg_TempLoc1)
        else
        endif
        set udg_IIV = udg_IIV + 1
    endloop
    // Initialize Systems
    call TriggerExecute( gg_trg_NPS_Initialization )
    call TriggerExecute( gg_trg_Load_Items )
    call TriggerExecute( gg_trg_Order_Test )
    call TriggerExecute( gg_trg_Icons )
    call TriggerExecute( gg_trg_Indestructable_Doors )
    call ConditionalTriggerExecute( gg_trg_Meet_the_King_Quest )
    call ConditionalTriggerExecute( gg_trg_Setting )
    call ConditionalTriggerExecute( gg_trg_Declaration )
    call FogEnable(false)
    call FogMaskEnable(false)
endfunction

//===========================================================================
function InitTrig_Initialization takes nothing returns nothing
    set gg_trg_Initialization = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Initialization, function Trig_Initialization_Actions )
endfunction
just got 3 left to fix any ideas?
 
Last edited:
You can inline the top function.

ConditionalTriggerExecute is fine if you want to check the conditions before firing (saves code length which is a plus).

AdjustPlayerStateBJ is fine.

For the CreateNUnitsAtLoc you can change to CreateUnit. For the x/y parameters simply use (instead of the location) GetStartLocationX/Y.

Looks like you also have a typo - CPlayer instead of Player
 
Level 7
Joined
Aug 15, 2012
Messages
318
You can inline the top function.

ConditionalTriggerExecute is fine if you want to check the conditions before firing (saves code length which is a plus).

AdjustPlayerStateBJ is fine.

For the CreateNUnitsAtLoc you can change to CreateUnit. For the x/y parameters simply use (instead of the location) GetStartLocationX/Y.

Looks like you also have a typo - CPlayer instead of Player

I tried to inline it do I just add \\ to the function I tried that didn't work idk if I did something wrong or misinterpreted what the explanation of an inline was but it never worked with every attempt as for my other issues basically all fixed thanks everyne for the help
 
Status
Not open for further replies.
Top