• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Jass Button

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
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)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
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:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
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.
 
Level 6
Joined
Aug 26, 2016
Messages
99
morpheus-free-your-mind.gif
 
Top