• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] An interesting bug with GUI compiling into JASS

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
Well, since GUIers were complaining about not being able to make functions, even with a little Custom Scripts, or anything, (like they can do with locals), I came up with a theory, and gave it a test -- it worked!

When you have a GUI trigger such as

  • bleh
  • Events
  • Something Happens
  • Conditions
  • Actions
  • Do Something
Sure, you can add locals and stuff like this:

  • bleh
  • Events
  • Something Happens
  • Conditions
  • Actions
  • Custom Script: local real pi = 3.14159
  • Do Something
But it seemed, up till now, that you couldn't add functions.

Anyways, I found out that you can effectively cut short the 'Trigger_bleh_Actions' function block and inject your own functions into the 'actions' of GUI, with parameters, returns, and all that, and even put GUI in it!

Basically, you're cutting off the Actions function prematurely, then injecting function declarations, like this. (here's an example of a GUI trigger used solely to hold custom functions)

  • bleh
  • Events
  • Conditions
  • Actions
  • Custom Script: endfunction
  • Custom Script: function ZomgGUIParameterReturnFunction takes unit u, real cheese, real pie returns integer
  • Custom Script: return 5
Will still inject the normal 'endfunction' line at the "end of the Trigger_bleh_Actions" function. However, since the other endfunction cut it short, the next line is outside of any statements, and can thus declare a new function. Then, you don't need the final endfunction because GUI injects it in the hope of terminating 'Trigger_bleh_Actions'

This compiles a little weirdly, as it still takes default indenting, so that the result (actions only) would look something like

JASS:
function Trig_bleh_Actions takes nothing returns nothing
----endfunction
----function ZomgGUIParameterReturnFunction takes unit u, real cheese, real pie returns integer
----return 5
endfunction

(note - dashes represent spaces... for some reason, the JASS tag was removing the spaces)

So sure, the indenting is a little nasty, but if you don't plan on converting it anyways... I just thought people may find this interesting
 
Level 9
Joined
Jul 27, 2006
Messages
652
Cool

Wow, that could be useful...
Of coarse this is still JASS not GUI so it wouldnt pass in GUI comps and it would mess up a trigger?
The only function being triggered by the event is ended by adding a function. So since you cant forward referance you would have a slight problem... But you could always use ExecuteFunction and it might work quite well...
 
Level 11
Joined
Jul 12, 2005
Messages
764
Well, they could write those functions into the custum script section of the map (you know, i'm talking about that thing that nobody can explain where and what it is :D). It's easier than writing those 'endfunction'-s and such. BUT, it's interesting that you discovered PurplePoot! I'd never thought of it...
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
That's actually how I guessed it x.x

Anyways, you can't put all JASS in a GUI trigger, as Custom Script tags crash the map after they reach a certain length

And pask -- the Custom Script section is JASS, so that's not really different than putting it in a JASSified "Trigger". Also, you can put GUI actions in the functions this way, so even a GUIer who knows these 2 trick lines (plus how to call a function through Custom Script tags) can make their own functions like this
 
Status
Not open for further replies.
Top