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

wc3 reforged & lua

Status
Not open for further replies.
Level 17
Joined
Apr 27, 2008
Messages
2,455
Hi everybody.

I'm curious about the ability to use lua instead of jass.
For example does it provide associative dynamic arrays as lua tables , can we call C functions,
is there a garbage collector, and so one.

Or it's only about the lua syntax ?
 
Last edited:
Level 9
Joined
Mar 26, 2017
Messages
376
A map in lua mode runs on a lua VM with all expected functionality of lua 5.3.
For instance, it is not needed to declare variables, functions can be dynamically called, and metatable functionality can be used.

A known difference from standard lua is that since a recent patch, the GC functions can no longer be accessed (it could cause desync).
GC still works, but we cannot do anything to influence it. According to DrSuperGood there is a custom implementation now that handles GC in a synchronous manner.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
ok, nice to know ty.

It makes vJass/wurst/cjass/whatever less interesting now i suppose, unless maybe there are projects to make them generating lua code instead of jass ?
So for once lua would be used as a first language generated by an other one.
But well what i'm saying, how many users in the world are interested to that lol
Not to mention backward compatibilities issues.
 
Level 9
Joined
Mar 26, 2017
Messages
376
I can't think of any reason to use those as lua does things better.
Perhaps if you want to use existing plug-n-play resources that are made for jass/vjass/etc.

It should be mentioned that because of lua dynamic typing, wrong type inputs for functions no longer get picked up with the syntax checker. Small mistakes cause thread crashes, and debugging is quite painful, especially if you just switched over to lua.

For this reasons, some mappers prefer a Typescript implementation having type safety and syntax check, which will be translated into lua code.
There is a guide on this: cipherxof/wc3-ts-template
 
Level 18
Joined
Jan 1, 2018
Messages
728
Don't wanna derail the thread but I'm getting a bit tired of seeing people subjectively recommending typescript instead of being objective and listing all available options...
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Hmm i just bought and downloaded reforged and i feel a bit dumb.
So now jasshelper and japi are included in the official editor.
Well, that's cool but when i try to write lua code in the trigger editor it try to interpret it as jass code.
I didn't find any option to disable jasshelper nor japi.

What do i need to know ?

Or the editor doesn't support it and we must edit the map script directly ?
 
Last edited:
Level 5
Joined
Jul 31, 2020
Messages
103
Hmm i just bought and downloaded reforged and i feel a bit dumb.
So now jasshelper and japi are included in the official editor.
Well, that's cool but when i try to write lua code in the trigger editor it try to interpret it as jass code.
I didn't find any option to disable jasshelper nor japi.

What do i need to know ?

Or the editor doesn't support it and we must edit the map script directly ?

Not sure if I'm understanding correctly, but Scenario → Map Options... → Script Language: Lua
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
ok ty, however the script language field is grey, i can't change it to lua.
I need to setup lua maybe ?
I built it on windows 10 from source but maybe i need more configuration.
I thought it would have been embeded in warcraft 3.
 
Level 5
Joined
Jul 31, 2020
Messages
103
ok ty, however the script language field is grey, i can't change it to lua.
I need to setup lua maybe ?
I built it on windows 10 from source but maybe i need more configuration.
I thought it would have been embeded in warcraft 3.

As far as I know, it will only allow you to change that option if the map doesn't yet have scripts in it. As in, if you already have some JASS in there, it'll be greyed out. I just opened up the editor to check on this, actually. In a blank map, I can change it, but in a map where I have scripts, it's greyed out.
 
Level 20
Joined
Jul 10, 2009
Messages
479
Unfortunately, you can't use Jass with Lua, so re-enabling the Jass is rather pointless.
I know, old thread, but just to debunk myths:
You can use Jass within lua code by encapsulating the Jass code in //! endusercode and //! beginusercode.

For instance, the following would work in a lua-map:

JASS:
--Jass code:
//! endusercode
function b takes nothing returns string
    return "Hello World"
end
//! beginusercode

--lua code:
function a()
    print(b())
end

Still I agree that mixing Jass and lua in one map is pointless. You can access Jass code from lua functions, but I don't know a way to do the opposite.
 
Status
Not open for further replies.
Top