• 🏆 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!

Lua, embedded jass

Status
Not open for further replies.
According to posts from 1.31 PTR it is possible to have jass code in a Lua map. To do so one has to tell the compiler that Lua code ends now. The one adds jass code and after the jass code is done, one says that Lua continues. This is done with:
//! endusercode
//! beginusercode

This embedded jass will end as Lua in the resulting map script and can be used in the Lua code. The jass has to be normal jass, no extended version but it can have any amount of global blocks.

Example:
Lua:
-- Lua code

//! endusercode
//jass code
function MyJassFunction takes integer a, integer b returns nothing
 call BJDebugMsg("MyJassFunction: " + I2S(a)+ " " + I2S(b))
endfunction
//! beginusercode

-- Lua code
TimerStart(CreateTimer(), 0, false, function()
    MyJassFunction(4, 8)
end)

When that is placed into a Lua map the game will at 0s run MyJassFunction (tested in Warcraft 3 1.31 and 1.32.8). Beaware that the shown way of selfexecution is not multiplayer safe.

Why I even know this? Or wanted to know it.
I wanted to add custom written Lua functions to the GUI-TriggerData which only supports jass right now. If one tries without this definitions in jass the compiler throws a Lua transpiler error pointing to the custom GUI-Actions using the Lua functions which can not be found in jass.
 
Status
Not open for further replies.
Top