Jass+lua?

_whelp

New Member
Reaction score
54
Sorry for the spam but...

JASS:

//! externalblock extension=lua ObjectMerger $FILENAME$
//! i local message = "\"Why did he have to die?\""
//! i local msg = assert(io.open("jass\\\\hellotheremate.j", "w"))
//! i msg:write("function HTM takes nothing returns nothing\n")
//! i msg:write("local string msg = " .. message .. "\n")
//! i msg:write("call KillUnit(gg_unit_hpea_0001)\n")
//! i msg:write("call BJDebugMsg(msg)\n")
//! i msg:write("endfunction")
//! i msg:close()
//! endexternalblock
//! import "hellotheremate.j"

scope LuaTest initializer onInit
    private function onInit takes nothing returns nothing
        call HTM()
    endfunction
endscope


It really works! AHA!
 

Nestharus

o-o
Reaction score
84
Yup


So right now me and Azlier are pushing for import to run 2x, once before lua and once after this way it'll solve the double save issue and make everyone's life a little easier.

The next are lua tags similar to zinc tags-

JASS:

//! lua
//! endlua


this way you aren't writing //! i on every single line


For cJASS I'm pushing for them to fix the $ replacement with t's so that lua can be used.

The next thing I'm trying to get them to do is lua { } and #lua


From here, we need to be able to run lua directly into the lua interpreter if no exe is specified (to lower compile time).


Also perhaps we can get these into the jass pack distribution-
http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/
http://www.thomasandamy.com/projects/CPB/
 

Jesus4Lyf

Good Idea™
Reaction score
397
my maps are protected
Irrelevant.

Anyway, you guys just need import to run after external blocks, none of this "run twice" stuff, as far as I can see. You should better define your reqs.
JASS:
//! lua
//! endlua

That defeats the point of the //! tag in the first place - compiler instructions. It would also slaughter the ability to blend lua and JASS init funcs at the same time.
 

Nestharus

o-o
Reaction score
84
You'd still have //! i


Also the reason for double import is because jass files may have Lua in them =). Remember, not everyone writes all of the JASS in the maps.

The double import is very important. I've seen quite a few cases where groups are working on maps together and using an svn repository to store the code.
 

weaaddar

New Member
Reaction score
6
Hooray for a crazy idea that actually worked [on the second time]. Now, I wonder can you open inputwar3map.j (i.e. the file you are using) for more preprocessing abuse?

Just imagine implementing Template sby using lua and replacing stuff found in your map using <>, and then creating the right structs on demand. Would be nuts.
 

Nestharus

o-o
Reaction score
84
ofc you can.

Don't know why you'd want to do that though ><


I think all you need is a Lexical JASS Generator thing. From here you also need a global block.

These are quotes from my posts on JassHelper thread so everyone can catch up

Ok, so here are some necessities for Lua : )

the import command mentioned above by Azlier

#2- lua blocks like Zinc (//! lua, //! endlua)

atm writing pure lua is insane ; o.

Shouldn't be that difficult to do =).

#3- being able to run lua without having to run it through something would be nice =).

Ok, after some further working with Lua I think there needs to be a central exe for running the lua and passing lua into the various exes that the lua blocks might be using. This will allow for one global lua block so that the lua blocks can communicate with each other. It'll also let lua change from exe to exe (ObjectMerger to FileMerger etc) and it'll also allow for scripts that use no exe.


Each given block of lua would be properly scoped. For example, if you had local variables within a block, another lua block wouldn't be able to access them. This just means put each lua block passed into the central exe inside of do blocks, lol.


I think it should be included in the standard jass newgen pack. This core is just really important so that lua can communicate with lua in other sections of that map : o.

All of this JASS generation stuff would also be better in C (in the core) and called from Lua.

From here, you might also want to include-
http://www.tecgraf.puc-rio.br/~diego...nal/luasocket/

http://www.thomasandamy.com/projects/CPB/


LuaSocket would allow for online libraries and what not if someone wanted that. On the other hand, a script might be a trojan downloader ><. Really though, goods outweigh the possible bads ; ).

CPB would allow for easy C and C++ resources rather than the current style ><.

Who wants to write the C Core to process the Lua and delegate it to exes? : D

Or maybe JassHelper can do that itself

Who knows : o.


edit
Temporary Alternative To Lua Core

All Lua code must be within a macro and cannot run macros. It is up to the user to implement the code by running the macro.

No code may run itself. All code must be instanced by the user via Lua.

All code will initially be in a block determined by the map maker. Any code that requires the use of another block needs to generate the JASS file for that block as well as the code (single run).



For writing JASS, code will do its own lexical stuff by instantiating a new lexical thingie mabob, lol. At the end, the user generates the JASS code by just passing in lexical.code to JASS.generate. This will ensure all necessary code is generated and will make it so that there is only one //! import for all JASS code generated by Lua.

All Lua code should be completely split from JASS (obviously).


So the user determines the block that all of the Lua runs in and that's that. If the user wants other blocks, they follow the same paradigm if they want to generate JASS or use any of the Lua packages =).

This is only solution I can think of.
 

Nestharus

o-o
Reaction score
84
Writing out JASS via Lexical elements. Lexical just means block objects that you can write inside of. Example, lexical 1: struct, lexical 1-1: method, lexical 1-2: var, lexical 2: function, lexical1-1.write(var)
JASS:
struct
    method
        //written var from write
        var
    endmethod
    var
endstruct
function
endfunction
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
I'm sure I'm not the only one who has no idea what the heck that even means.
And isn't willing to read more than a 3 line explanation.

I'm not sure I'd even begin reading it. :nuts:
 
Reaction score
341
Unzip to your newgen directory.

JASS:
//!lua
do
lua
stuff
here
no //!
is
required
//!endlua


I wrote this in like 5 min so there are some annoyances.
  • war3map.j is double spaced?
  • Has to be //!lua with no spaces. (same for endlua)
 

Attachments

  • luastuff.zip
    545.6 KB · Views: 302

Nestharus

o-o
Reaction score
84
You running it through some sort of core lua thingie mabob though so you can change the blocks in real time and have all the scripts in the same scope? : o.

or might this just be a start :)

more specifically, what kind of code does it generate? does it just add //! i to each line?
 
Reaction score
341
nes said:
You running it through some sort of core lua thingie mabob though so you can change the blocks in real time and have all the scripts in the same scope? : o.

or might this just be a start

It's just a simple program which extracts the war3map.j, replaces everything inside lua tags with [ljass]//! i + text[/ljass] and re-imports it.
 

Nestharus

o-o
Reaction score
84
//! i + text you mean


Ok, you can improve it by putting them all through a common external block that can take exes (other external blocks) which it can then pass like normal.

Also through should be a space (like zinc..). Follow convention : D.

JASS:

//! lua
    //! block exe
        --lua code here!!
    //! endblock
    --lua code here!!
//! endlua


It'd pass in all of the lua script into that core lua processor thingie and that'd it turn run the lua and properly send arguments off to the other exes.

Furthermore, in lua, let people name the block almost like a file and let people use require. When they require something, it places one block of lua above or w/e.

For JASS generation, you can let me worry about that ; ). It'd be nice if you auto included like the core Lua thing I'm going to write for easy JASS generation at the top of the lua global script block ;o. Not super done yet though (needs some serious revisions).

Then all we need to do is fix the //! import and all should be good and also have it auto import the given file following convention.

So use the map name.lua, like
My Map.lua

So it should always import that file automatically. A var should be provided to retrieve the file name : ).

This should be most of the necessary stuff ; P.
 

Nestharus

o-o
Reaction score
84
You cant' directly compile that into anything.

You'd need to make an exe to handle it

That's the only way you'd be able to merge it all into one environment and be able to send off portions of that environment to other exes.


I frankly don't know enough about how all the tools in the background of jasshelper operate to do that ; |. I could make the exe, you could merge it into a global block, but I can't even figure out what parameters to take, otherwise I could probably manage it ><.
 
Reaction score
341
Have you used the tool?
Does it work properly?

I plan on just fixing the double spacing and allow for freedom with //! lua and thats it.
Unless ofc enough people want more stuff.

And no, I wouldn't use this tool most likely.

EDIT: Well, this worked.

JASS:
//! import &quot;test.j&quot;

scope wtf initializer onInit
    private function onInit takes nothing returns nothing
        //! externalblock extension=lua ObjectMerger $FILENAME$
        //!lua
            function CreateFile(name, contents)
                local file = assert(io.open(&quot;jass\\\\&quot;..name, &quot;w&quot;))
                file:write(contents)
                file:close()
            end
            CreateFile(&quot;test.j&quot;, &quot;function test takes nothing returns nothing\ncall BJDebugMsg(\&quot;Hello World!\&quot;)\nendfunction\n&quot;)
        //!endlua
        //! endexternalblock
        call test()
    endfunction
endscope
 

Nestharus

o-o
Reaction score
84
The tool doesn't do what I specifically need ; D.

I'll try it out though sec. Will edit post in one second after I tried it out : ).

edit
doesn't do anything to the text within the block ;o
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs
  • Monovertex Monovertex:
    @The Helper I'm really not seeing the "Signature" link in the sidebar on that page. Here's a screenshot:
  • The Helper The Helper:
    I have reported it - I was wondering why nobody I have given sigs to over the last few years have used them
  • The Helper The Helper:
    Ghan has said he has fixed this. Monovertex please confirm this fix. This was only a problem with people that had signatures in the upper levels like not the special members but the respected members.
  • The Helper The Helper:
    Here is a better place to manage this stuff https://www.thehelper.net/account/account-details which I think should be way more visible
  • The Helper The Helper:
    I am hoping that online user count drop is finally that TikTok bot banned
  • Ghan Ghan:
    I added the filter last night.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top