Jass Button

Status
Not open for further replies.
It's the same API, you just switch the syntax around a bit when converting from Lua to Jass:
Lua:
local frame = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
vJASS:
local framehandle frame = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
 
I need an article or example on how to get started.
Tasyen has you covered:

I'll convert the ScriptDialogButton example to Jass to get you on the right track:
vJASS:
 function MyFirstButtonCallback takes nothing returns nothing
    local framehandle frame = BlzGetTriggerFrame()
    call DisplayTextToPlayer(Player(0), 0, 0, BlzFrameGetName(frame) + " was Clicked")
    set frame = null
 endfunction

 function MyFirstButton takes nothing returns nothing
    local trigger t = CreateTrigger()

    // create a new Button which inherits from "ScriptDialogButton"
    local framehandle frame = BlzCreateFrameByType("GLUETEXTBUTTON", "MyScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "ScriptDialogButton", 0)
    // place the Button to the center of the Screen
    call BlzFrameSetAbsPoint(frame, FRAMEPOINT_CENTER, 0.4, 0.3)
    // set the Button's text
    call BlzFrameSetText(frame, "My Button Text")
 
    // register the Click event
    call BlzTriggerRegisterFrameEvent(t, frame, FRAMEEVENT_CONTROL_CLICK)

    // this happens when the button is clicked
    call TriggerAddAction(t, function MyFirstButtonClicked)
 
   set t = null
   set frame = null
 endfunction
If you search around you can find other examples and maps you can download, some of which are in Jass. But going from Lua to Jass really isn't all that difficult if you spend the time to understand the subtle differences. Also, a good excuse to finally learn Lua and perhaps make the switch, it's far better than Jass.
 
Last edited:
How and with what to convert the code?
Convert it with your mind. Look at how similar most of this is:
Lua:
local frame = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
vJASS:
local framehandle frame = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
Lua:
    -- place the Button to the center of the Screen
    BlzFrameSetAbsPoint(frame, FRAMEPOINT_CENTER, 0.4, 0.3)
vJASS:
    // place the Button to the center of the Screen
    call BlzFrameSetAbsPoint(frame, FRAMEPOINT_CENTER, 0.4, 0.3)
Lua's comments use double -- Jass uses double //
Lua doesn't use the words set or call. Jass does.
Lua doesn't need to declare the variable type. Jass does.

Again, same API, same functions, same logic, just different syntax.
 
morpheus-free-your-mind.gif
 
Status
Not open for further replies.
Back
Top