- Joined
- Jul 18, 2010
- Messages
- 2,377
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:
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:
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.
//! 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.