Jass+lua?

Saw somewhere Vexorian say that you could write plain LUA in JASS with //! i directive, but in his guide I read it only works with external lua files and that the //! i passes arguments into those files.

Is there any way to write plain old LUA in WE and have it run? I've been trying and nothing works ^_^. Wouldn't even know how I would print text, lol. Tried the print for printing code, but that ofc did nothing =P.
 

weaaddar

New Member
Yeah, you can do it with external block and object merger as an example. As a note, its compile time only, and you can't get the value out unless it has a readable sideeffect.

I.e. setting an ItemName you can't query the lua directly, but you can use the Jass native. You can't use Lua for jass code generation either, so you probably want to mix textmacros and lua.

something like I do in my defunct idea of DbMod here:: http://www.thehelper.net/forums/showthread.php?t=142836
 
er... I wouldn't be using anything inside of object merger at all...

so how would I be able to use plain lua code.. like lua functions etc, and then use macros to run the code using that lua code??

your example didn't show me anything -.-. It was pretty much using the functions in the ObjectMerger.
 

weaaddar

New Member
Object merger works because it accepts a $FileName$ you need some sort of external block that accepts an extension. The example has something interesting in it, in that I do some compile time code as I generate I built up an ability and use arrays and what not. I do some native lua operations, namely table creation, concats and multiplication.

ObjectMerger and text macros is a good idea, as you can sneak initialization stuff of data that doesn't have natives into a libraries/structs onInit method, while you generate this data for the object data.


You could try to just write plain lua use [ljass]//! i whatever[/ljass] but as I said you can't use lua to generate jass code. Maybe you can use lua to write a .j file that you can import or preload (maybe?), but unless you have a side effect like object merger does whats the point. There is no way for the Jass to communicate with it.

Lua would be a really great pre-processor for jass as then you'd have a very powerful turing complete macro system that you can use to generate C++ style templates.
 
Yup.. I was hoping to use it for generation of JASS code, hence the reason why I said your example didn't help at all : )
 

weaaddar

New Member
I think if you write an extension that creates a .j file that you can use lua to import that'll work. I just don't know how to do that.
 
It can't be external or it'd be too much work to implement -.-.

I need it to be written in WE.


Now, I could do a full add on and try to make it a standard to make it so people can write plain LUA as a preprocessing language and just put #'s in front of the lua lines, but I really don't want to go that far. Actually it wouldn't be that much of a stretch from what's here atm =), lol. Just enable print and you're set =).
 

weaaddar

New Member
Oh I mean do File I/O. Like in the lua create a text file then have a [ljass]//! import "fileYouMadeInLua.j"[/ljass] directive.

Something like::
JASS:
//! i LuaFileOpenHere("someFile.j",w+);
//! i OutToFile("function luaTest takes nothing returns nothing"..char(10).."endfunction");
//! i LuaCloseFile("someFile.j");
//! import "someFile.j"
...
call luaTest()

Of course again, I don't know lua so I can't say what the hell the commands are :p

This migth work though:: http://www.google.com/url?q=http://...zgQoAQ&usg=AFQjCNGZaKppdlSaKLCQoj3gTvqXdD7R3Q
 

Troll-Brain

You can change this now in User CP.
So basically what you will be allowed to do ?
Everything ?

EDIT: Ofc i mean manipulate the map on compilation, like edit the script, the ability file and so one.
 
I've been reading Programming in Lua First Edition since yesterday : )

edit
this doesn't seem to run (according to Azlier)
Code:
do
	local f = assert(io.open("my cheese.boo", "w"))
	f:write("Hi")
	f:close()
end
We're trying to use I/O library from WE ><

Edit
Azlier got it working : D. Actually, he found out he was looking in the wrong directory, it was working entire time : p.

edit
JASS:

//! externalblock extension=lua ObjectMerger $FILENAME$
    //! i do
        //! i local f = assert(io.open(&quot;jass\\\\test.j&quot;, &quot;w&quot;))
        //! i f:write(&quot;struct Hello extends array&quot;)
        //! i f:write(&quot;endstruct&quot;)
        //! i f:close()
    //! i end
//! endexternalblock
///! import &quot;test.j&quot;
 

Azlier

Old World Ghost
This is how to create .j files in the NewGen\jass folder. Exciting, if only //! import worked with them on the first save and not the second.

JASS:
//! i 	assert(io.output(&quot;jass\\Test.j&quot;, &quot;w&quot;))
//! i 	io.write(&quot;Cool stuff.&quot;)
 
Programming in Lua First Edition
The C Book

Get cracking


This would also allow you to look online and dynamically download/import models and files. It also allows you to easily look through an online repository for code and insert whatever code you are using, etc.

The applications for this are boundless.

And you should store your io in a local variable in a do block to prevent global collisions Azlier!!

ha
 

Azlier

Old World Ghost
We thought about that. You should join chat. If possible.
 
Er.. they can't because this is totally jasshelper..


btw, this does not work with cJASS because the team screwed up macros. They replace $ with t's... so the FILENAME is always invalid..

that kinda makes me mad..
 
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

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top