Jass+lua?

_whelp

New Member
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!
 
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™
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.
 
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
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.
 
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.
 
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
 
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

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?
 
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.
 
//! 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.
 
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 ><.
 
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
 
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.
  • tom_mai78101 tom_mai78101:
    I have a GIF though
  • tom_mai78101 tom_mai78101:
    In the GIF, I've configured it so the lower the "Main Value" is, the better. I had to compress it pretty far down though.
  • tom_mai78101 tom_mai78101:
    And this is the thread with the video that shows the wall clip. https://tasvideos.org/Forum/Topics/23453
    +2
  • tom_mai78101 tom_mai78101:
    Hmm, about the Headline News, I noticed threads are being moved into the subforum (Health News, Environmental News, etc.). When that happens, the TH Forum Home page loses the articles, and instead would show old articles posted 1 or 2 weeks ago.
  • tom_mai78101 tom_mai78101:
    What do we do with the Home page?
  • Ghan Ghan:
    I added those forums to the filter for that widget.
    +1
  • tom_mai78101 tom_mai78101:
    Oh nice. They're back. Thanks.
  • tom_mai78101 tom_mai78101:
    Now I think it makes more sense for me to put news in their own subforums, without worry.
  • The Helper The Helper:
    Awesome Ghan thanks! I was purposely not moving the first 15 news articles in Headline news to the different subforums but I guess I don't have to do that now?
  • tom_mai78101 tom_mai78101:
    Question: Is there a way to remove thread redirects? It creates a copy of the moved thread and takes up space, and I am leaning towards wanting to remove them in the Headline News. But if they have an expiration date, I guess I'm fine with it.
  • The Helper The Helper:
    If you move a thread please leave a permanent redirect. You can delete any redirects after 6 months. The redirects are left to help Search Engines find the moved content.
  • tom_mai78101 tom_mai78101:
    What if you move the permanent redirect, not the thread?
  • The Helper The Helper:
    I think that works but I have not messed with it. You can delete redirects though if you have to that will not delete the original thread
  • The Helper The Helper:
    if a redirect ends up in the same forum as the post it goes to though I think the redirect drops or fails or something but they are not bugged out and when you are working on an indirect the original post is safe.
  • The Helper The Helper:
    Happy Early Friday :)
    +1
  • V-SNES V-SNES:
    Happy Friday :)
  • tom_mai78101 tom_mai78101:
    Fun Friday for me
  • tom_mai78101 tom_mai78101:
    Happy Fun Friday to all.
    +2
  • The Helper The Helper:
    Happy Sunday everyone!!!
  • V-SNES V-SNES:
    Happy Sunday!!!
    +1
  • jonas jonas:
    Happy monday :p
  • jonas jonas:
    Everyone hates mondays?
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • jonas jonas:
    Happy belated tuesday

    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