HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simple vJass "Problem"

05-12-2009, 06:05 PM#1
Linaze
All right, to begin, I am a complete "newbie" at Jassing, so please try to keep it as simple as possible when trying to help me.

Anyways, my problem is relatively simple, I guess.

I have a trigger called NewTrigger, just for learning purposes.
Collapse JASS:
globals
    quest q = CreateQuest()
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    set gg_trg_NewTrigger = CreateTrigger()
    call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction
When I use the Syntax Checker it complains about line 11, claiming that gg_trg_NewTrigger is an undeclared variable, which in my eyes, it isn't. Does anyone have any clue as to what I should do to get my solution solved?
I am using JNGP, if that matters.

Any help would be greatly appreciated, thanks in advance.
05-12-2009, 06:11 PM#2
moyack
Do this:

Collapse JASS:
function InitTrig_NewTrigger takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Trig_NewTrigger_Actions)
    set t = null
endfunction
05-12-2009, 06:14 PM#3
Linaze
The syntax checker now says it works, but the map crashes before even load, saying something like:
"FATAL ERROR
...
Memory could not be read."
05-12-2009, 06:55 PM#4
moyack
weird... I'm pretty sure it's in other part of the code.

EDIT: The problem is taht you're setting the quest at map init, and this can't be done in that stage, you should do something like this:

Collapse JASS:
globals
    quest q = CreateQuest()
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
    call DestroyTimer(GetExpiredTimer())
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.1, false, function Trig_NewTrigger_Actions)
endfunction
05-12-2009, 07:17 PM#5
Linaze
Using your code moyack, still same problem. :/

"This application has encountered a critical error:

FATAL ERROR!

Program: C:\Program Files\Warcraft III\War3.exe
Exception: 0xC00000005 (ACCESS_VIOLATION) at 001B:6F475270

The instruction at '0x6F465270' referenced memory at '0x00000010c'.
The memory could not be 'read'.

Press OK to terminate the application."
05-12-2009, 07:40 PM#6
Bobo_The_Kodo
Try this then:

Collapse JASS:
globals
    quest q
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    set q = CreateQuest()
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
    call DestroyTimer(GetExpiredTimer())
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.1, false, function Trig_NewTrigger_Actions)
endfunction
05-12-2009, 07:49 PM#7
cosmicat
It's safer to pause timers before destroying them...

Collapse JASS:
globals
    quest q
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    set q = CreateQuest()
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
    call PauseTimer(GetExpiredTimer())
    call DestroyTimer(GetExpiredTimer())
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.1, false, function Trig_NewTrigger_Actions)
endfunction
05-12-2009, 09:40 PM#8
moyack
Quote:
Originally Posted by cosmicat
It's safer to pause timers before destroying them...

Collapse JASS:
globals
    quest q
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    set q = CreateQuest()
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
    call PauseTimer(GetExpiredTimer())
    call DestroyTimer(GetExpiredTimer())
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.1, false, function Trig_NewTrigger_Actions)
endfunction
If the timer is non periodic, pausing it is a non necessary step.

@Linaze: Could you disable the trigger and run the game? just to ensure this trigger is the cause.
05-13-2009, 02:50 AM#9
Fledermaus
Quote:
Originally Posted by Linaze
When I use the Syntax Checker it complains about line 11, claiming that gg_trg_NewTrigger is an undeclared variable, which in my eyes, it isn't. Does anyone have any clue as to what I should do to get my solution solved?
I am using JNGP, if that matters.
Were you using the "Syntax Check" button? Because that button doesn't work, it will show you all sorts of "errors" that are not even there. The proper way to check for errors is to save the map.

EDIT: Moyack, I'm pretty sure you can create quests at map init..

Just tested the original code and it's crashing because you're creating the quest in the global declaration. This works fine though:

Collapse JASS:
globals
    quest q
endglobals

function Trig_NewTrigger_Actions takes nothing returns nothing
    set q=CreateQuest()
    call QuestSetTitle(q,"Title")
    call QuestSetDescription(q,"QuestDesc.")
endfunction

function InitTrig_NewTrigger takes nothing returns nothing
    set gg_trg_NewTrigger = CreateTrigger()
    call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction
05-13-2009, 03:27 AM#10
cosmicat
I don't see how that's working fine, since there's no event to trigger those actions...

Meh, if you say it works, I guess it works.
05-13-2009, 03:41 AM#11
wraithseeker
I think he ticked run at map initialization.
05-13-2009, 03:47 AM#12
Alevice
well, he could call Triggerexceute somehwere