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:
    Make sure you keep checking out my news..
    +2
  • Jesus4Lyf Jesus4Lyf:
    Man, I made this account 15 years ago? Wild. :)
  • Ghan Ghan:
    Seeing J4L is definitely a blast from the past.
  • Jesus4Lyf Jesus4Lyf:
    Oh hey Ghan! Long time. :)
    +1
  • jonas jonas:
    J4L! What has happened in your life
  • Jesus4Lyf Jesus4Lyf:
    Hmm, how to summarize... Moved to the USA and got married. Became a professional software engineer and solution lead. Learning Godot for game dev. :)
  • jonas jonas:
    So you are pursuing game dev as a hobby? What industry is your dayjob in?
  • jonas jonas:
    FAANG?
  • Jesus4Lyf Jesus4Lyf:
    Not quite FAANG, less pay for a less hours/stress. Yeah, game dev as a hobby.
  • jonas jonas:
    makes sense. Do we have a hobby game dev subforum to showcase some work?
  • Blackveiled Blackveiled:
    Happy Thursday
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    TGIF!
  • The Helper The Helper:
    hey tom_mai please do not archive anymore news
  • Ghan Ghan:
    AMD Ryzen 7000 next week :D
    +1
  • The Helper The Helper:
    noice!
  • tom_mai78101 tom_mai78101:
    "hey tom_mai please do not archive anymore news" ----> Got it. What should we do with the "News Archive" subforum?
  • The Helper The Helper:
    I think leave it for real old news that cannot be sorted the reason we had it in the first place was a server issue that we do not have anymore. I don't want to get rid of the archive just not put anything in it for now until we figure it out more
  • The Helper The Helper:
    The side chat has nothing on the discord. it is not possible but the biggest thing on my wish list right now is a sidechat channel on the disord that hooks up to this...
  • Ghan Ghan:
    I've been selected for the Diablo IV beta.
    +1
  • Ghan Ghan:
    Woo!
    +1
  • The Helper The Helper:
    that is so cool
  • V-SNES V-SNES:
    Eh just noticed the new discord section on the side. Looks great!
    +1
  • Blackveiled Blackveiled:
    :( feels bad I can't ever get selected for any beta I sign up for. It's annoying as heck.
    +1

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top