• 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.

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