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
83
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
395
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
83
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
83
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
83
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

Nestharus

o-o
Reaction score
83
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
83
//! 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
83
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
83
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.
  • The Helper The Helper:
    Happy Friday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday Night!
    +1
  • The Helper The Helper:
    Going out of a town for the weekend will be back sunday night! Hope everyone has a great weekend!
    +2
  • The Helper The Helper:
    Happy Monday!
  • Ghan Ghan:
    Monday? Speak for yourself. :p
    +2
  • The Helper The Helper:
    Happy Taco Tuesday!
    +1
  • The Helper The Helper:
    Tacos! :)
  • The Helper The Helper:
    Check out the discord for taco pictures :) You cannot put pictures in this chat
    +1
  • The Helper The Helper:
    Damn here come the bots again - 193 online but they are totally invisible to any stats - bunch of bots!'
  • C cubanismo:
    Re: Taco Tuesday, if there were some way to share edible tacos over the internet, technology would be complete.
    +2
  • The Helper The Helper:
    One can only wish!
  • tom_mai78101 tom_mai78101:
    I'm back from Taiwan
    +1
  • The Helper The Helper:
    I am reorganizing the site I know nobody will notice but I am not done quite yet but the main forums order has been changed and there is a new news category in Other News which is all the remaining headline news stuff not categorized - Headline News is just the stuff that shows on the main page now and the news archive is off the main forums page
  • The Helper The Helper:
    and the real archive lives off of headline news
  • The Helper The Helper:
    Happy Monday!
  • V-SNES V-SNES:
    Happy Saturday!
  • The Helper The Helper:
    Happy Saturday Night!

    The Helper Discord

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top