HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS: What's wrong with this?

11-23-2007, 11:48 PM#1
Zandose
Am I doing something wrong here? I'm trying to debug another trigger and I can't get this one to work to help me. What am I doing wrong?
Collapse JASS:
scope test

globals
    real test1 = GetRectMinX(GetPlayableMapRect())
    real test2 = GetRectMaxX(GetPlayableMapRect())
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg(R2S(test1))
    call DisplayTextToForce( GetPlayersAll(), R2S(test2) )
endfunction

//===========================================================================
public function test takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( trig, 1.00 )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope
11-24-2007, 12:30 AM#2
MaD[Lion]
ehm... wat are u trying to do? u have functions, and they are not automatically called... And why do u put trigger into scope
11-24-2007, 12:37 AM#3
HINDYhat
Collapse JASS:
function GetPlayableMapRect takes nothing returns rect
    return bj_mapInitialPlayableArea
endfunction
and
Collapse JASS:
    rect               bj_mapInitialPlayableArea   = null

I'd assume that bj_mapInitialPlayableArea is assigned a value at map init, so you can't set the rect min/max values in global declarations. You could, though, in the InitTrig function, which you totally screwed up. It should be either:
Collapse JASS:
scope YourTriggerName
globals
real test1
real test2
endglobals
// blah conditions, actions

public function InitTrig takes nothing returns nothing
set test1=GetRectMinX(bj_mapInitialPlayableArea)
set test2=GetRectMaxX(bj_mapInitialPlayableArea)
// inittrig shiznit
endfunction
endscope
or
Collapse JASS:
library SomeName initializer YourInitFunction
globals
real test1
real test2
endglobals
//blah conditions actions

function YourInitFunction takes nothing returns nothing
set test1=GetRectMinX(bj_mapInitialPlayableArea)
set test2=GetRectMaxX(bj_mapInitialPlayableArea)
// inittrig shiznit
endfunction
endlibrary
11-24-2007, 02:39 AM#4
Zandose
@MaD[Lion]
Idk? I thought whenever you make a trigger to use a scope to hold the whole thing. Like the private function needs the scope to tell it that its linked to the public function. I guess I should go read a tutoral on this again.

Next question. Why won't this trigger start? Assuming I got it right this time?
Collapse JASS:
scope test

globals
    real test1
    real test2
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("123")
    set test1 = GetRectMinX(bj_mapInitialPlayableArea)
    set test2 = GetRectMaxX(bj_mapInitialPlayableArea)
    call BJDebugMsg(R2S(test1))
    call DisplayTextToForce( GetPlayersAll(), R2S(test2) )
endfunction

//===========================================================================
public function IntiTrig takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( trig, 1.00 )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope
11-24-2007, 02:50 AM#5
Vexorian
are you ever calling test_test?
11-24-2007, 02:57 AM#6
Zandose
@Vex
Are you talking about the scope? I thought the public function would start it all and that the scope just held everything together.

If thats not what your talking about then I'm lost.
11-24-2007, 03:17 AM#7
Vexorian
Quote:
Are you talking about the scope? I thought the public function would start it all and that the scope just held everything together.
well, you are quite wrong.
11-24-2007, 03:24 AM#8
Zandose
Quote:
Originally Posted by Vexorian
well, you are quite wrong.
Care to elaborate how I get this trigger to start up?
11-24-2007, 03:29 AM#9
Vexorian
You could just manually call test_test() from a place that is ever executed on map initialization.

You could also make the scope get the same name as the trigger and use a public InitTrig function, (this makes the scope's InitTrig to be used as the trigger's InitTrig function)

You can convert the scope into a library with initializer.

Collapse JASS:
scope test

globals
    real test1 = GetRectMinX(GetPlayableMapRect())
    real test2 = GetRectMaxX(GetPlayableMapRect())
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg(R2S(test1))
    call DisplayTextToForce( GetPlayersAll(), R2S(test2) )
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( trig, 1.00 )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope
This would work as long as you call the trigger "Test"
11-24-2007, 03:38 AM#10
HINDYhat
Isn't that what I said?
11-24-2007, 04:45 AM#11
Zandose
Quote:
Originally Posted by HINDYhat
Isn't that what I said?
Probably but I didn't understand.

Anyways, since I'm so noob at this, I don't get how I call the trigger. Is the trigger inside a scope inactive until it's called?
11-24-2007, 10:25 AM#12
Silvenon
Quote:
Originally Posted by HINDYhat
I'd assume that bj_mapInitialPlayableArea is assigned a value at map init, so you can't set the rect min/max values in global declarations.

Quote:
Originally Posted by PitzerMike
Hopefully InitBlizzard gets called before custom globals are initialized.

Quote:
Originally Posted by Pyrogasm
Collapse JASS:
globals
    constant real KB_MAPMINX = GetRectMinX(bj_mapInitialPlayableArea)
    constant real KB_MAPMAXX = GetRectMaxX(bj_mapInitialPlayableArea)
    constant real KB_MAPMINY = GetRectMinY(bj_mapInitialPlayableArea)
    constant real KB_MAPMAXY = GetRectMaxX(bj_mapInitialPlayableArea)
endglobals

I'm confused now.....
11-24-2007, 11:10 AM#13
Pyrogasm
To be honest, I'm not sure if that works, Silvenon. I guess it must, but I've never tested initializing those globals like that because I can't use globals blocks.
11-24-2007, 12:14 PM#14
Vexorian
It doesn't work, as in AT ALL.
11-25-2007, 10:38 AM#15
Silvenon
Pitzy The Great was wrong then......