• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] The Future of vJASS Coding

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
With the stuff I've been working on Lua, I'm starting to see how the layout of scripts may drastically change as new things become possible and as new methods become tried.

Currently, lua scripts are something of a pain to use as they are mostly snippets and have to be imported into each individual script via a runtextmacro. A snippet may only be 1 function, so 1 lua resource might use 10-20 snippets, meaning 10-20 cnps and 10-20 textmacros to run. Sounds like a pain doesn't it?

This is the thing I am seeing with lua now (and what I'll probably do). One of the lua snippets is something called JASS Write, which writes JASS files on to the user's hard drive so that they can be imported into the map. This is useful for dynamic script generation. What I am thinking is that lua can use this same methodology to install a script on to a computer so that it is auto usable in all maps. This will also allow scripts to automatically use the resources they require via an lua function called dofile.

What this means is that mass textmacros will no longer need to be run and once you have installed a script, you never need to install it again.

So firstly, I must point out that the usage of lua scripts will change. The past has always been textmacros. The future is now writing to harddrive and dofile : ).

The next point is object generation. The past has always been a single line externalblock. The future appears to be dynamic JASS scripts that store dynamically generated unit object ids into a global variable for use.

What more will the future bring? New systems that partially run on lua (template generation and etc)? New ways to install systems so that they can be configured for a map?

Perhaps, in projects, all objects will be made via lua now so that the object editors don't need access to the map. Perhaps, terrain editors will not need access to the map either as they can place doodads and etc and then look into the JASS script within the map and rip out the code (thus having a terrain dummy map that contains the terrain code for them to edit).

I see so many possibilities in JASS now, things that currently aren't possible in sc2.

As we march to the future, what new resources and maps await us? : )


So my current question regarding the future of lua scripts (since I'm the primary lua coder, lol) is what would people prefer for lua script usage?

Would people prefer mass textmacro usage or would people prefer installation for all maps + dofile?

textmacro usage means script has to be pasted into map
installation means script doesn't need to be pasted into map

textmacro usage means that to even use a resource, a textmacro must be used (if you use it for 4 scripts, all 4 scripts have to run the macro)

dofile is nearly the same, but it can be nested, meaning that there will be much less dofiles than there will be textmacros.

There will be possible future questions.

Let us together define what we expect in lua resources from now on =).
 
We already have textmacro usage so I say go for it if you can make it. Might as well have another option. :p

Wait a minute, but are Lua Scripts = vJASS Scripts too? Or is Lua a different version of JASS?

LUA is a different language all together. You can use LUA in NewGen for access to the object editor, data generation, importing, and some other things... (however, LUA is strictly for map editing, meaning if you try to incorporate LUA into JASS and running the script ingame, it won't let you) :)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Perhaps, terrain editors will not need access to the map either as they can place doodads and etc and then look into the JASS script within the map and rip out the code (thus having a terrain dummy map that contains the terrain code for them to edit).

Doodads, destructables and units (except ones that are referenced via triggers) are all done in separate object files unrelated to the jass script. Further more doodads can never be referenced in JASS as they lack type information. Destructables and Units that are used in triggers will obviously get move to the script.

The fact is there is little future to WC3 modding. SC2 can do so much more than WC3 and more efficently. If I want a jump spell in SC2, I go to the data editor and make a beautiful parabola jump. If I want a jump spell in WC3 I must go through all kinds of leaky trigger code and people will always find better ways to do it..

The only way WC3 modding could ever further improve would be if blizzard gets the game maintained, which I am afraid I do not see happening.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
We already have textmacro usage so I say go for it if you can make it
I can write the resource required for it in <2 minutes (submission included). Porting all of the scripts over to the resource would take 20 mins tops given the number of resources I'd be updating ; D. It's no problem moving over ; P, just gotta find the time to do it.

Hold on, to give you an idea as to why I think installation might be a better option-

JASS:
//LUA_JASS_IO: hiveworkshop.com/forums/jass-functions-413/snippet-lua_jass_io-177419/
//LUA_FIND_LINE: hiveworkshop.com/forums/jass-functions-413/snippet-lua_find_line-177418/
//LUA_TRIM: hiveworkshop.com/forums/jass-functions-413/snippet-lua_trim-177439/
//LUA_OBJECT_ID: hiveworkshop.com/forums/jass-functions-413/snippet-lua_object_id-176943/
//LUA_STRING_EXPLODE: hiveworkshop.com/forums/jass-functions-413/snippet-lua_string_explode-176944/
//LUA_JASS_GLOBALS: hiveworkshop.com/forums/submissions-414/system-lua_jass_globals-185917/

Those are all the resources required by 1* snippet.

So that's 7 textmacros you have run to use the function in that one snippet on top of 7 resources you have to collect for every map =).

With installation, that's 1 dofile you have to run on top of 7 resources you have to collect only one time for all maps.

The fact is there is little future to WC3 modding. SC2 can do so much more than WC3 and more efficently. If I want a jump spell in SC2, I go to the data editor and make a beautiful parabola jump. If I want a jump spell in WC3 I must go through all kinds of leaky trigger code and people will always find better ways to do it..

It is too bad that the limitations in sc2 make the maps I typically work on impossible to do : |, so I'm stuck with wc3 regardless. Furthermore, there are some maps (very few) on wc3 that can't be done on sc2 because of said limitations ; P.

/sad face

But back to the actual conversation on the future of JASS scripting, not the future of wc3 ; P.

This is the resource I'd virtually cnp to make the lua one for ease of use and standardization. As can be seen, only a few things need to be changed ; P.
JASS:
//! textmacro LUA_JASS_IO takes FILE_NAME
    //! i do
        //! i local PATH = "jass\\luajass.$FILE_NAME$.j"

        //! i function jassread()
            //! i local f = io.open(PATH, "r")
            //! i if (f == nil) then
                //! i return nil
            //! i end
            //! i local code = f:read("*all")
            //! i f:close()

            //! i return code
        //! i end

        //! i function jasswrite(code)
            //! i local f = io.open(PATH, "w")
            //! i f:write(code)
            //! i f:close()
        //! i end
    //! i end
//! endtextmacro

edit
Question, is there a way to retrieve the map's filename in the lua? I haven't seen any way to do this ; \.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Create/EditFile of course. If you are able to dynamically write code, you can also write that the result should do textmacros, it's mightier. Now I don't know which security flaws there could be.

Like said, I would want to have interaction between the different features of a map: object editor objects, terrain, jass code, imports, other resources in the mpq, etc. To effectively do so, there would be a parent language that unites them. Basicly, maybe there will be tools to create the whole map archive in the future besides normal/enhanced editor and have the mentioned ability to entrench different things.

Idk if this will be in lua but try what you see.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
dofile is mightier than textmacros as those can be nested ; ). Without a dofile, you will have to write out every textmacro a snippet uses for every instance of that snippet. This means, like for a function, if you want it to use a function that used 6 other resources, u'd have to write out all 7 textmacros in your little function. If you had 3 functions, you'd have to write them all out for each of the 3 functions.

This is the reason I am trying to get away from the macros ; ).

Create/EditFile of course

???
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
It is too bad that the limitations in sc2 make the maps I typically work on impossible to do : |, so I'm stuck with wc3 regardless. Furthermore, there are some maps (very few) on wc3 that can't be done on sc2 because of said limitations ; P.

/sad face

The thing is that the sc2 is getting updated unlike wc3 (unfortunately). After some time sc2 probably won't have those limitations.
 
Level 19
Joined
Oct 15, 2008
Messages
3,231
Hmm... Blizzard did say they'll still update Warcraft III though, so we could expect the same for Warcraft:)
 
Level 19
Joined
Oct 15, 2008
Messages
3,231
Hmm... How about trying to create certain programs to update it legally? That way we can improve the coding stuff thingy.
 
Level 19
Joined
Oct 15, 2008
Messages
3,231
I'm sure many people would still prefer to play Warcraft III (Like most of my friends), so why not try out something creative:)
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Further more doodads can never be referenced in JASS as they lack type information.

that's not completely true
native SetDoodadAnimationRect takes rect r, integer doodadID, string animName, boolean animRandom returns nothing
makes you able to modify the animation of a doodad (and if you change the animations to look like what you want to happen with the doodad you can do pretty much with it)
there are also special animation names like show/hide/soundon/soundoff
nevertheless it might be much harder to archive a certain effect with it

but I agree with you that wc3 is about to die
though I won't switch to starcraft
I dislike the theme and making games with c instead of jass or galaxy gives so many more opportunitiy
the advantage of having a gameengine and all the art stuff done already is nice but full control is better

unfortunately I can't contribute much to the topic since my knowledge about LUA is negligibly small

by the way...did blizzard fix the preload hack already?
 
Level 19
Joined
Oct 15, 2008
Messages
3,231
Well, it's a good thing Blizzard fixed it there, but is there a way the preload hack could be used to do something useful for a map?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I got 'er done

http://www.hiveworkshop.com/forums/submissions-414/snippet-lua_file_header-186775/

gg

>: D

Now I have to update alllllllllllllllll of my lua resources and allllllllllllllllll of my jass resources that use my lua resources and get people to update allllllllllllllll of their resources that use my lua resources >: o.

If you don't feel like going to the link, you can do this now
JASS:
//! externalblock extension=lua FileExporter $FILENAME$
    //! runtextmacro LUA_FILE_HEADER()
    //! i installscript([[function Hello() print("hi") end]], "1.0", "MyScript")
    //! i usescript("MyScript")
    //! i installjass([[
        //! i struct Tester extends array
            //! i private static method onInit takes nothing returns nothing
                //! i call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "hello world")
            //! i endmethod
        //! i endstruct
    //! i ]], "1.0", "MyScript")
//! endexternalblock

Template
http://www.hiveworkshop.com/forums/submissions-414/snippet-lua_file_header-186775/
JASS:
//MyScript 1.0
//! externalblock extension=lua FileExporter $FILENAME$
    //! runtextmacro LUA_FILE_HEADER()
    //! i installscript([[
    //////////////////////////////////////////////////////////////////
    //code



    //end code
    //////////////////////////////////////////////////////////////////
    //! i ]], "1.0", "MyScript")
//! endexternalblock


Have I earned myself a cookie yet?

Yes, I even introduced version control ->"1.0"

If a person has 4.5 installed, they can't install anything lower ;D. I was lazy though, I just used tonumber(), so ur stuck with 2 number version control rather than the spiffy 4.

I also learned something interesting... you don't have to do craziness with the generated jass script anymore... I, by accident, found a workaround that makes the imports run after the lua jass generation. Good? Yes.

No, the imports are done nestedly, so first the script in WE is run (imports, lua, etc), then the imports are run, then their imports are run, and etc. This means that if you generate jass via lua in WE and import that file within an imported file, it won't throw an error. Good? Yes. I rock >: D. The only imported file is a hub file for jass scripts.

Initialization is easy if you don't want to wait to install a script-
JASS:
//! externalblock extension=lua FileExporter $FILENAME$
//! i installjass("", "1337", "EmptyScriptThatDoesAbsolutelyNothing")
//! endexternalblock
 
Status
Not open for further replies.
Top