Jass+lua?

Nestharus

o-o
Reaction score
84
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
Reaction score
6
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
 

Nestharus

o-o
Reaction score
84
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
Reaction score
6
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.
 

Nestharus

o-o
Reaction score
84
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
Reaction score
6
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.
 

Nestharus

o-o
Reaction score
84
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
Reaction score
6
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.
Reaction score
85
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.
 

Nestharus

o-o
Reaction score
84
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
Reaction score
461
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;)
 

Nestharus

o-o
Reaction score
84
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
Reaction score
461
We thought about that. You should join chat. If possible.
 

Nestharus

o-o
Reaction score
84
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
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/

      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