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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top