HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Dialog box JASS problem

07-13-2010, 04:33 PM#1
sPyRaLz
To whomever is able to help, I'll gladly +rep if the forum allows.
I'm trying to create a dialog box that pops up immediately after the map loads,
I originally created the file as a trigger, and modified it to JASS. The Jass version wont load.. It just takes me to a black screen when i try launch my campaign.
Any ideas anyone? Any advice will be greatly appreciated. Thanks in advance.

PS: I've attached the campaign file it might help troubleshoot the error. I'm using NewGen WE pack 5d.

Jass Code:
Collapse JASS:
scope Menu initializer Init
    globals
        public button array ba[5]
    endglobals

    private function Actions takes nothing returns nothing
        local unit h = null
        local dialog d
        local gamecache gc = null
        local location l = GetRectCenter(GetPlayableMapRect())
        
        call TriggerSleepAction( 0.50 )
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Main")
        call DialogSetMessage(d, "Main Menu")
        set ba[0] = DialogAddButton(d, "New Game",0)
        // ----------------------------------------------------------
        set gc = InitGameCache("roti00.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[1] = DialogAddButton(d, "Autosave: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti01.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[2] = DialogAddButton(d, "Save 01: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti02.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[3] = DialogAddButton(d, "Save 02: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti03.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[4] = DialogAddButton(d, "Save 03: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        call DialogDisplay(Player(0), d, true)
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        local trigger MenuTrg = CreateTrigger(  )
        call TriggerAddAction( MenuTrg, function Actions )
    endfunction
endscope

Original Working Trigger:
Trigger:
Main Menu BAK
Collapse Events
Map initialization
Conditions
Collapse Actions
Wait 0.50 seconds
Game - Display to (All players) the text: Main
Dialog - Change the title of Dialog to Main Menu
Dialog - Create a dialog button for Dialog labelled New Game
Set DialogButton[0] = (Last created dialog Button)
-------- ---------------------------------------------------------- --------
Game Cache - Create a game cache from roti00.w3v
Game Cache - Restore Kael of Heroes from (Last created game cache) for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
Set Hero = (Last restored unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero Not equal to No unit
Collapse Then - Actions
Unit - Remove Hero from the game
Dialog - Create a dialog button for Dialog labelled Continue
Set DialogButton[1] = (Last created dialog Button)
Else - Actions
-------- ---------------------------------------------------------- --------
Game Cache - Create a game cache from roti01.w3v
Game Cache - Restore Kael of Heroes from (Last created game cache) for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
Set Hero = (Last restored unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero Not equal to No unit
Collapse Then - Actions
Unit - Remove Hero from the game
Dialog - Create a dialog button for Dialog labelled (Save 01: + (Location + ( - + Time)))
Set DialogButton[2] = (Last created dialog Button)
Else - Actions
-------- ---------------------------------------------------------- --------
Game Cache - Create a game cache from roti02.w3v
Game Cache - Restore Kael of Heroes from (Last created game cache) for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
Set Hero = (Last restored unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero Not equal to No unit
Collapse Then - Actions
Unit - Remove Hero from the game
Dialog - Create a dialog button for Dialog labelled (Save 02: + (Location + ( - + Time)))
Set DialogButton[3] = (Last created dialog Button)
Else - Actions
-------- ---------------------------------------------------------- --------
Game Cache - Create a game cache from roti03.w3v
Game Cache - Restore Kael of Heroes from (Last created game cache) for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
Set Hero = (Last restored unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero Not equal to No unit
Collapse Then - Actions
Unit - Remove Hero from the game
Dialog - Create a dialog button for Dialog labelled (Save 03: + (Location + ( - + Time)))
Set DialogButton[4] = (Last created dialog Button)
Else - Actions
-------- ---------------------------------------------------------- --------
Dialog - Show Dialog for Player 1 (Red)
Attached Files
File type: w3nRotI.w3n (62.7 KB)
07-13-2010, 05:40 PM#2
Tot
try
Collapse JASS:
scope Menu initializer Init
    globals
        public button array ba[5]
    endglobals

    private function Actions takes nothing returns nothing
        local unit h = null
        local dialog d
        local gamecache gc = null
        local location l = GetRectCenter(GetPlayableMapRect())
        call DestroyTimer(GetExpiredTimer())
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Main")
        call DialogSetMessage(d, "Main Menu")
        set ba[0] = DialogAddButton(d, "New Game",0)
        // ----------------------------------------------------------
        set gc = InitGameCache("roti00.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[1] = DialogAddButton(d, "Autosave: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti01.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[2] = DialogAddButton(d, "Save 01: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti02.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[3] = DialogAddButton(d, "Save 02: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        set gc = InitGameCache("roti03.w3v")
        set h = RestoreUnit(gc, "Heroes", "Kael", Player(0), GetLocationX(l), GetLocationY(l), 0)
        if ( h != null ) then
            call RemoveUnit( h )
            set ba[4] = DialogAddButton(d, "Save 03: " + "Location" + " - " + "Time",0)
        endif
        // ----------------------------------------------------------
        call DialogDisplay(Player(0), d, true)
    endfunction
//===========================================================================
    private function Init takes nothing returns nothing
        call TimerStart(CreateTimer(),0.01,fale,function Actions)
    endfunction
endscope

the timer waits 'till the game actually starts...maybe this fixes your problem, cause dialogs can't be displayed on init and the scope's init-func is run during init.
07-14-2010, 02:00 PM#3
sPyRaLz
I just gave it a try, still the same bug. Game displays a blacks screen when i try to load the first map of the campaign. : (
I suspect its a problem with the campaign editor failing to compile the map.. When i compiled the map as a standalone, it worked.
I reimported the standalone, and it also worked.
07-14-2010, 02:15 PM#4
Fledermaus
Try change the initializer to Actions
07-14-2010, 06:53 PM#5
sPyRaLz
Hm.. I'm pretty convinced that its an issue with the campaign editor, When i save my maps while they are opened via campaign editor, The compile time seems a little shorter. Scopes don't seem to be recognized. I have to compile separately then load the map to the campaign to get things working. Either ways, its lookin good. Thanks for the feedback!
07-15-2010, 12:15 AM#6
Fledermaus
Oh yeah, there's something about JNGP not working well with Campaigns I think.
07-15-2010, 08:26 PM#7
Bribe
You have to save the map outside of the campaign in JNGP, then re-import the map back into the campaign. The use of 3rd party programs like JEdit or NotePad++ helps a lot in situations like this.
07-16-2010, 04:04 AM#8
sPyRaLz
Quote:
Originally Posted by Bribe
You have to save the map outside of the campaign in JNGP, then re-import the map back into the campaign. The use of 3rd party programs like JEdit or NotePad++ helps a lot in situations like this.

Thanks for verifying that. I've never used those before. Are they able to compile? Or do they just help you check your syntax errors and stuff? If they can't compile I don't see how it makes any difference as I still have to port the map into the campaign 1 way or another.
07-16-2010, 04:53 AM#9
Bribe
They provide syntax highlighting.

To be perfectly honest, I do about 0.001% of my work in the actual editor (pretty much for debugging or choosing special effects) and the rest I do in JEdit.
07-16-2010, 01:16 PM#10
YourName
Quote:
Originally Posted by Bribe
They provide syntax highlighting.

To be perfectly honest, I do about 0.001% of my work in the actual editor (pretty much for debugging or choosing special effects) and the rest I do in JEdit.
Eww. I just can't understand why people code outside of the editor. I regularly test my code whenever I write something to keep the problems as small as possible.
07-16-2010, 04:31 PM#11
Bribe
I average about 1 syntax error for every 150 lines, not worried about that.
07-16-2010, 05:42 PM#12
sPyRaLz
Quote:
Originally Posted by YourName
Eww. I just can't understand why people code outside of the editor. I regularly test my code whenever I write something to keep the problems as small as possible.

Ditto to that. Programming huge text of code without regular testing intervals messes me up real bad. I find its much harder to track down bugs that don't spit out any error messages.
07-16-2010, 05:55 PM#13
Bribe
Open/Save/Close time in sessions is sped up an average of 58,000 %

When you're coding large amounts of script in order to implement features and framework, there's nothing you need more than fast coding. JEdit line-splitting, rectangular selection, syntax highlighting, find & replace blows NewGen out off the face of the earth.

Notepad ++ smart highlighting is amazing.
07-16-2010, 06:22 PM#14
YourName
It's about testing your stuff ingame regularly, not writing 1000 lines of code outside of the game and afterwards track down each bug you might find.
07-16-2010, 07:21 PM#15
Bribe
I'll concede everyone codes differently. This is an example of a system where 99.99% of the work was done in Notepad++ and JEdit. The slow speed and lack of features in NewGen aggrivates me, so I prefer to do it this way.