• 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.

[JASS] Simple Jass Question

Status
Not open for further replies.
Level 3
Joined
Feb 17, 2008
Messages
41
I'm starting to learn JASS, but when I try something that I think is right it crashes! I found out what crashes its the first thing I inputed. Anyone help? and give an explaination on why it crashed? The Synttax checker says that it's udg_PlayerRace is an undecleared variable




JASS:
function Trig_Building_Hall_Func002C takes nothing returns boolean
    if ( not ( GetResearched() == 'R000' ) ) then
        return false
    endif
    return true
endfunction

//function CreateWorkers takes nothing returns nothing
 //if (udg_PlayerRace == "Orc") then
 //else
 //endif
//endfunction

function Trig_Building_Hall_Actions takes nothing returns nothing
    local unit u = GetResearchingUnit()
    local player p = GetOwningPlayer(u)
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local timer t = CreateTimer()
    local string sfxmdl = "units\\undead\\Abomination\\Abomination.mdl" //playerholder

    if ( Trig_Building_Hall_Func002C() ) then
    set udg_PlayerRace[GetPlayerId(p)] = "Orc"
    call RemoveUnit(u)
    call CreateUnit(p,'ogre',x,y,270)
   // call TimerStart(t, .5, true, function CreateWorkers)
    call TriggerSleepAction(2.00)
    //call DestroyTimer(t)

    else
    endif
endfunction



//===========================================================================
function InitTrig_Building_Hall takes nothing returns nothing
    set gg_trg_Building_Hall = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Building_Hall, EVENT_PLAYER_UNIT_RESEARCH_FINISH )
    call TriggerAddAction( gg_trg_Building_Hall, function Trig_Building_Hall_Actions )
 
Last edited:
Level 7
Joined
Jul 20, 2008
Messages
377
Did you create the variable in the variable editor (Ctrl + B)? Did you spell it with the right capitalization? JASS is case-sensitive.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Open your variable editor (Cntrl + B while in trigger editor) and check if you have the following variable:

PlayerRace
--> which is a string array

JASS:
//function CreateWorkers takes nothing returns nothing
    //if (udg_PlayerRace == "Orc") then
    //else
    //endif
//endfunction
Can't work correctly because there is no "p" variable. You're using udg_PlayerRace while there's no "p" defined.
 
Status
Not open for further replies.
Top