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

JNGP Lua Edition - Combining JASS/vJass/Lua

Status
Not open for further replies.
JNGP Lua Edition

Archive Password: "thw" (without quotes)

Google thinks JNGP is malware so it has to be password protected. You can read more about it on the official JNGP page.

As it currently stands in the latest World Editor, you cannot mix scripting languages. You must pick either JASS or Lua. You also cannot require scripts in WC3's Lua so we are essentially forced to type all of our code in an external editor and paste it back into the trigger editor. Because of these limitations I decided I wanted to try and integrate Lua into the editor while also allowing you to code in JASS or vJass.

How to Setup
  • Make sure you have a copy of an older version of WC3. You can download the 1.26 game files here. It should work with any patch that contains the MPQs.
  • Download extract jassnewgenpack-lua-1.1.0.zip.
  • Edit "findpath.lua" (in the jngp folder) to point to your WC3 directory and 1.31 executable. There are comments in the file which explain further.
  • Run "NewGen WE.exe".

Using Lua

In order to use Lua you must wrap your code in //! lua and //! endlua tags. For example:

Lua:
//! lua
function Trig_Basic_Example_Actions()
    TimerStart(CreateTimer(), 1.00, true, function()
        print("Lua!")
    end)
end
//! endlua
Now, if you want call a Lua function from within JASS you must use the //# +nosemanticerror tag to prevent PJASS from throwing errors. For example:

JASS:
//! lua
function Trig_Basic_Example_Actions()
    TimerStart(CreateTimer(), 1.00, true, function()
        print("Lua!")
    end)
end
//! endlua

//# +nosemanticerror
function InitTrig_Basic_Example takes nothing returns nothing
    set gg_trg_Basic_Example = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Basic_Example, 0.00 )
    call TriggerAddAction( gg_trg_Basic_Example, function Trig_Basic_Example_Actions )
endfunction
The same rules apply when you are using vJass.

External Lua Files

Because JassHelper's import directive wasn't working properly I made a quick one specifically for Lua files.

JASS:
//! luaimport "luascripts\test.lua"
You can use relative or absolute paths. This should allow you to easily code in a 3rd party code editor if that's what you want.

Lua VSCode Integration
 

Attachments

  • jngplua.w3x
    16.4 KB · Views: 370
  • jassnewgenpack-lua-1.1.0.zip
    16.1 MB · Views: 2,064
Last edited:
Updated to 1.1.0
  • Implemented recursive includes. You can import a script from the editor, and those scripts can include other scripts.
  • Combined all the luahelper scripts into a single executable (saves +10MB).

includes.png
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
Do you know if this gets around the issue of maps requiring all triggers be removed or a new map being created in order to allow Lua scripting?

I think Lua is great, but the integration with exisiting script is difficult for laymen and I fear will reduce its adoption among the novice parts of the community who have shied away even from JASS.
 
Do you know if this gets around the issue of maps requiring all triggers be removed or a new map being created in order to allow Lua scripting?

I think Lua is great, but the integration with exisiting script is difficult for laymen and I fear will reduce its adoption among the novice parts of the community who have shied away even from JASS.

Yes you can open any old map and start using Lua. You don't need to disable anything.

However you cannot open a map that was created with the 1.31 PTR in this JNGP, at least until/if I finish the convert map feature.
 
Level 3
Joined
Nov 21, 2016
Messages
18
I tried to use this jngp and encountered an error while trying to run test map, but after pressing 'ok' map still starts. But for some odd reasons it leaks local variables when running in such way. Starting the same map from the game client does not produce leaks though.

UPDATED:
I've tested map once again and realised that only temporary test map get properly converted to Lua, but the real one does not. So the question is how to make map convert to Lua on save? And is it ok for Lua to leak handles even after nulling? I'm not quite sure how Lua works internally but I think would not be possible to implement things like closures with access to local variables from the enclosing function if local variables behaved as before, in JASS.
 

Attachments

  • fss.jpg
    fss.jpg
    54.6 KB · Views: 440
  • test_leaks.w3m
    16 KB · Views: 237
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Pretty sure I had this working the other week, however, while I am able to open/save/compile I cannot run test. When I try to test, it hangs for a second then appears like it spams a few command prompts then closes them. It goes onto open the newer blue dialog box to Repair or Launch TFT. I then press launch and it is the main menu of Wc3 1.31.

Made a test map just to check bare bones, obviously can open/save/compile, still opens the main menu as stated above. However, if I place testmap in maps wc3 folder for the 1.26 version and go in single player I am able to test it. That will be a rather big inconvenience.

Any insight would be appreciated!
 
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Any advice?

When I try to test w/ lua code, I get an error "Failed to execute script luahelper"

Edit: Got word from TriggerHappy on discord, he says it needs to be updated, and that he is in the process of moving over to Ceres.
 
Last edited:
Level 7
Joined
Jul 8, 2009
Messages
42
-- This should be the path to your WC3 directory that contains the game MPQs
path = C:\Users\brand\Documents\iccup_war3_en

-- This should be the path to the latest Warcraft III.exe
testmap_exe = C:\Program Files (x86)\Warcraft III\x86_64

is this right?
once i try to open nothing happens
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
I have a problem, for some reason from certain point using your editor the JassHelper doesn't count my edits I'm doing so it always displays error even I fixed that error, why?

This is the map:
 

Attachments

  • The escape of draenei vBeta23.w3x
    4.8 MB · Views: 56
Level 28
Joined
May 14, 2021
Messages
1,095
I have a problem, for some reason from certain point using your editor the JassHelper doesn't count my edits I'm doing so it always displays error even I fixed that error, why?
You should advertise about that, so, what are my options?
All 3rd party WEs (like JNGP and WEX) no longer supported anymore.
Currently, normal WE (Reforged) by Blizzard has many features that JNGP and WEX previously had (like JassHelper and Lua), so those 3rd party ones might be obsolete as of the latest patches.
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
All 3rd party WEs (like JNGP and WEX) no longer supported anymore.
Currently, normal WE (Reforged) by Blizzard has many features that JNGP and WEX previously had (like JassHelper and Lua), so those 3rd party ones might be obsolete as of the latest patches.
The thing is I'm doing my map in the 1.26, so I need those editors if I wanna use JassHelper.
 
Level 28
Joined
May 14, 2021
Messages
1,095
when the problem started it displays a lot "luahelper can't run"
You mean "Failed to execute script luahelper" or something similiar?

One explanation is that "luahelper" error thing relies on your installation folder so it has to be fixed before you can start the JNGP. In order to make the JNGP work, you must have both Warcraft 3 1.31 and 1.26 installed on your computer.

1.For Warcraft 3 1.26, please check the first post above.
2.For Warcraft 3 1.31, download from this one

After installing both games, download JNGP Lua, then change the following lines in "findpath.lua":
1.path: The directory where you just installed Warcraft 3 1.26.
2.testmap_exe: The directory where you just installed Warcraft 3 1.31.

I don't know if this trick still works today (due to the fact regular WE comes with JassHelper and Lua), but if you got the older JNGPs you're luck.
 
Status
Not open for further replies.
Top