What would cause a dialog trigger to malfunction like this?

Hivoyer

New Member
Reaction score
0
ok so basically im making a simple dialog with jass,but it malfunctons for some reason...i don't get it,if i do it with gui exactly the same way,it works fine,but when I write it in jass it doesn't trigger and the entire map script crashes,all other triggers stop working too,debug messages won't come out either.Here is the function if you're interested:

JASS:
function Trig_Race_Selection_Buttons_Actions takes nothing returns nothing

    local player clicker = GetTriggerPlayer()
    local real X = GetLocationX(GetStartLocationLoc(GetPlayerStartLocation(clicker)))
    local real Y = GetLocationY(GetStartLocationLoc(GetPlayerStartLocation(clicker)))
    local integer ID = GetPlayerId(clicker)
    local real range = 0
    local integer index = 0
        
    if( GetClickedButton() == dialog_race_buttons[0] ) then
    
    set player_race[ID] = 0
    
    call CreateUnit(clicker,'h000',X,Y,270)
    
    set range = GetRandomReal(-600,600)
    
    loop
    exitwhen(index == 3)
    
    call CreateUnit(clicker,'h006',X+range,Y+range,270)
    
    set index = index + 1
    endloop

    set range = GetRandomReal(-800,800)
    set index = 0
    
    loop
    exitwhen(index == 24)
    
    call CreateUnit(clicker,'o000',X+range,Y+range,270)
    
    set index = index + 1
    endloop
    
    set range = GetRandomReal(-1200,1200)
    set index = 0
    
    loop
    exitwhen(index == 5)
    
    call CreateUnit(clicker,'n00E',X+range,Y+range,270)
    
    set index = index + 1
    endloop
    
    set range = GetRandomReal(-2400,2400)
    set index = 0
    
    call CreateUnit(clicker,'h008',X+range,Y+range,270)
    
    set range = range + GetRandomReal(-300,300)
    
    loop
    exitwhen(index == 4)
    
    call CreateUnit(clicker,'h009',X+range,Y+range,270)
    
    set index = index + 1
    endloop
    
    elseif ( GetClickedButton() == dialog_race_buttons[1] ) then
    elseif ( GetClickedButton() == dialog_race_buttons[2] ) then
    else
    endif

endfunction

function InitTrig_Race_Selection_Buttons takes nothing returns nothing

    set gg_trg_Race_Selection_Buttons = CreateTrigger(  )
    
    call TriggerRegisterDialogEvent(gg_trg_Race_Selection_Buttons,dialog_race)

    call TriggerAddAction( gg_trg_Race_Selection_Buttons, function Trig_Race_Selection_Buttons_Actions )

endfunction


dialog_race is a global dialog variable and dialog_race_buttons is a global dialog button variable.They're properly initiated and the dialog showed before i made the above function
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
please use [noparse]
JASS:
[/noparse] when posting triggers like this, and this is obviously GUI converted to jass, post the gui triggers please
 

Hivoyer

New Member
Reaction score
0
there's 4 ifs in 1 function,thats not possible in gui

you can clearly see the local variables LOL
 

TheLegend

New Member
Reaction score
10
you can have as many if's as you want in a function
i bet its the dialog initialization :D
here's how i used to solve those problems, create a dialog and its buttons at map init but dont show it, use variables to identify it, name them the sam as in the system. In the system add "udg_" in front of the variables, if it fails let me know and post the dialog init function
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
i said converted, that doesnt mean you cant edit it, and you clearly have a gg_trg_ variable which is only used in gui conversions, and i used locals in gui

and you have elseifs that were clearly a copy from an else part of an if then else function that were copied, seeing as they have no calls in them, either that or you really dont know how to write jass, in that case theres a lot that you did wrong here, those elseifs that have no calls, use [ljass]local trigger t = CreateTrigger()[/ljass] to add actions to your trigger, and seperate the lines of every encapsulation with a tab, or 4 spaces

EX:

JASS:
function Example takes nothing returns nothing
    if (true) then
        call DoSomeActions()
    elseif (true) then
        call DoSomeOtherActions()
    endif
endfunction


not sure if that really does anything to the script, dont believe it does but it makes it WAY easier to read
 

Hivoyer

New Member
Reaction score
0
but why would the problem be in the initialization,it gives no syntax errors and if I do it with GUI,it works perfectly
 

TheLegend

New Member
Reaction score
10
yyyy sorry for the spam but i remembered something that causes map crashes :D
JASS:

GetConvertedPlayerID()

JASS:

GetPlayerID()

arent the same if u used them somewhere. Oh and the first cant read 0 it crashes the map and the second cant read -1. Limit the integer
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
JASS:
function GetConvertedPlayerID takes player p returns integer
    return GetPlayerID(p) + 1
endfunction


thats all convertedp layer ID does, since red (player 1) Player Id is 0, player 2 is 1, etc
 

TheLegend

New Member
Reaction score
10
i think i found it :D
JASS:
if GetClickedButton() == dialog_race_buttons[0] then

i think the crash is that an array cant start from 0


oh and GFreak those functions cant go below or above some value which causes map crashes
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
array always starts from 0

you create the unit for the clicker player, not their ID, it takes an integer not a player, use the ID variable
you cant force feed a function that takes integers to take a player lol
 

Elfian

New Member
Reaction score
0
Arrays can't start from 0? Pfahahahhaah, seriously?! Arrays ALWAYS start from 0. Get your shit right. The problem with this piece of code is most likely that you are registering an event to a NULL dialog handle (you are using it in the InitTrig_ before actually = DialogCreate()-ing it). Have a look at your code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top