• 🏆 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!

[Solved] Syntax Error - undeclared variable

Status
Not open for further replies.
Level 7
Joined
Aug 15, 2012
Messages
318
fixed everything thanks to everyone that helped me

Hey I have an update I have a trigger Forgotten Forest that I am too nooby to figure out the issue if someone can give me a nudge in the right direction I would appreciate it.
I understand its undeclared but how would I declare it heres a picture of the error I get.
kQwQs.png

JASS:
function Trig_Entering_Forest_Actions takes nothing returns nothing
    if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true then
        // create entering area text
        call Entering_Area_CreateText("The Forgotten Forest", gg_rtc_Forgotten_Forest)
    endif
endfunction

function Entering_Area_CreateText takes string name, rect area returns nothing
    // a local to store the text tag
    local texttag tt = CreateTextTag()
    local location Pt = gg_rtc_Forgotten_Forest()
    
    // configure the text tag
    call SetTextTagText(tt, name, TextTagSize2Height(15.0))
    call SetTextTagPos(tt, GetRectCenterX(gg_rtc_Forgotten_Forest), GetRectCenterY(gg_rtc_Forgotten_Forest), 0.0)
    call SetTextTagColor(tt, 255, 255, 255, 51)
    call SetTextTagLifespan(tt, 3)
    call SetTextTagFadepoint(tt, 2.5)
    call SetTextTagPermanent(tt, false)
    call SetTextTagAge(tt, 0)
    call SetTextTagVisibility(tt, true)

    // local declared local handle bugfix
    set tt = null
    set Pt = null
endfunction
sorry for double post....
 
Last edited by a moderator:
The function "Entering_Area_CreateText" should be above "Trig_Entering_Forest_Actions", like so:
JASS:
function Entering_Area_CreateText takes string name, rect area returns nothing
    // a local to store the text tag
    local texttag tt = CreateTextTag()
    local location Pt = gg_rtc_Forgotten_Forest()
    
    // configure the text tag
    call SetTextTagText(tt, name, TextTagSize2Height(15.0))
    call SetTextTagPos(tt, GetRectCenterX(gg_rtc_Forgotten_Forest), GetRectCenterY(gg_rtc_Forgotten_Forest), 0.0)
    call SetTextTagColor(tt, 255, 255, 255, 51)
    call SetTextTagLifespan(tt, 3)
    call SetTextTagFadepoint(tt, 2.5)
    call SetTextTagPermanent(tt, false)
    call SetTextTagAge(tt, 0)
    call SetTextTagVisibility(tt, true)

    // local declared local handle bugfix
    set tt = null
    set Pt = null
endfunction

function Trig_Entering_Forest_Actions takes nothing returns nothing
    if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true then
        // create entering area text
        call Entering_Area_CreateText("The Forgotten Forest", gg_rtc_Forgotten_Forest)
    endif
endfunction

Also, it expects you to have a region named "Forgotten Forest". Go to your map and open the region palette. Create a new region and name it Forgotten Forest. That is where the text will be placed.
 
Level 7
Joined
Aug 15, 2012
Messages
318
Also, it's gg_rct not gg_rtc for preplaced rects.

wow always the simple stuff haha thanks guys your awesome fixed it all
so after fixing all these issues my map initialization has a issue where it cant create the unit in the trigger I have tried placing it in different places and even tried adding a new line thinking maybe it would work but to me avail and being a noob at this I failed.
JASS:
function Trig_Initialization_Actions takes nothing returns nothing
    set udg_CreepTable = InitHashtable()
    set udg_TempLoc1 = GetStartLocationLoc(udg_IIV)
    set udg_IIV = 0
    loop
        exitwhen udg_IIV > 9
        if GetPlayerSlotState(Player(udg_IIV)) == PLAYER_SLOT_STATE_PLAYING then
            call CreateUnit( Player(udg_IIV), 'e000', GetStartLocationX(udg_IIV), GetStartLocationY(udg_IIV), 0)
            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)
        set udg_IIV = udg_IIV + 1
        else
        endif
    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
 
Last edited:
Level 7
Joined
Aug 15, 2012
Messages
318
Does the rest of the trigger work or does it not run at all?

Also, you will crash the thread at the line call RemoveLocation(udg_TempLoc1) at the second loop iteration as you try to destroy a location on every loop iteration, but only create it once (at the top of your function).

so what is saying is I dont need to null this if its only ran once? It is created once per player no or would it not work like that? nothing works doesnt give gold and the trigger is set to run at map initialization should I link the map and see if its possibly one of the triggers it runs at init? (note ive tried removing all the conditions to run triggers and it still doesnt work)
 
Level 7
Joined
Aug 15, 2012
Messages
318
You must move set udg_TempLoc1 = GetStartLocationLoc(udg_IIV) inside the loop, as you only get this on top of your trigger once, but destroy the location on every loop iteration.


Also, a function must start with "InitTrig_" to actually get executed at map initialization.

changed the top one didnt change anything about not firing the trigger.
Also I tried implementing that IntTrig_ but no matter what I tried it gave me a parse error do I need the ""
update here's a version inside a map@ http://www.hiveworkshop.com/forums/pastebin.php?id=glzw38
[HIDDEN="Jass"][code=jass]function InitTrig_Trig_Initialization_Actions takes nothing returns nothing
set udg_CreepTable = InitHashtable()
set udg_IIV = 0
loop
exitwhen udg_IIV > 9
if GetPlayerSlotState(Player(udg_IIV)) == PLAYER_SLOT_STATE_PLAYING then
set udg_TempLoc1 = GetStartLocationLoc(udg_IIV)
call CreateUnit(Player(udg_IIV), 'e000', GetStartLocationX(udg_IIV), GetStartLocationY(udg_IIV), 0)
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)
set udg_IIV = udg_IIV + 1
else
endif
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
// Map Header Custom Code

// SimError by Vexorian at wc3c.net

// Modified version

function IRS_SimError takes player p, string s returns nothing
local string msg = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00" + s + "|r"
local sound error = CreateSoundFromLabel ("InterfaceError", false, false, false, 10, 10)

if GetLocalPlayer() == p then
call ClearTextMessages ()
call DisplayTimedTextToPlayer (p, 0.52, 0.96, 2.00, msg)
call StartSound (error)
endif
endfunction

function IRS_SimNotify takes player p, string s returns nothing
local string msg = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00" + s + "|r"
local sound notify = CreateSoundFromLabel("Hint", false, false, false, 10, 10)
if GetLocalPlayer() == p then
call ClearTextMessages()
call DisplayTimedTextToPlayer (p, 0.52, 0.96, 2.00, msg)
call StartSound (notify)
endif
endfunction


[/code][/HIDDEN]
 
Last edited:
Status
Not open for further replies.
Top