• 🏆 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!

[Snippet] LUA_GET_VAR_OBJECT

Level 31
Joined
Jul 10, 2007
Messages
6,306
Updated to fix a bug apparent in certain situations

->
JASS:
            //! i id = getobjectid(base, objtype)
            //! i while ((c.code()):findline("'" .. id .. "'") ~= nil) do
                //! i id = getobjectid(base, objtype)
            //! i end

from

//! i id = getobjectid(base, objtype)

This way variables have a 0% chance of colliding ;). If a variable is already present with an id in it, that id won't be used.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
GetVarObject 2.0 with an extended API >: D

JASS:
//function getvarobject(base, objtype, varname, import)
//function getvarobjectname(value)
//function getvarobjectvalue(objectname)
//function updateobjects()

I was doing a huge object script a little while ago and after 4 hours of waiting i decided i needed to make this run a lot better/faster >: D. Furthermore, I didn't necessarily want all of my objects to have variables associated with them as it was better to store them into an array >: O.

So it's faster and variables no longer have to be imported into the map : D.


And yea, because this entire system changed, you have to reinstall all the JASS scripts that use this that you are using (all being 2 atm), lol ;D.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Made an optimization to this.

2.0.1.0 moved from depending on an imports hashtable to reading directly out of the JASS file to see if a variable was imported or not. This was done so that variables could be deleted directly out of the JASS file without corrupting the entire system
JASS:
globals
constant integer ABILITIES_UNIT_INDEXER='A!!!'
constant integer UNITS_UNIT_EVENT='n!!!'
endglobals

Deleting UNITS_UNIT_EVENT from the script would unimport it. In the old version, it'd still be registered as imported.

2.0.2.0 reads the entire imports JASS file one time and loads it into a hashtable. The previous version read out of a string every time the function was called. While the ini will be slower, large amounts of calls should run much faster.

This is the script that loads the imports file into a table (placed above the function in initialization)
JASS:
    //! i local imports = {}
    //! i do
        //! i local s,k = vars2:find("constant integer ")
        //! i local s2,k2
        //! i while (s ~= nil) do
            //! i s2,k2 = vars2:find("=", k)
            //! i imports[vars2:sub(k+1, s2-1)] = true
            //! i s,k = vars2:find("constant integer ", k2)
        //! i end
    //! i end
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Updated to 3.0.0.1

3.0.0.0 runs epic fast (created more than 8000 objects in around 1 minute)

Furthermore, previous objects have almost no bearing on how long future saves take

In 2.0.0.0, with more than 8000 objects in the map, a simple updateobjects() took 20 minutes. In 3.0.0.0, a simple updateobjects() took maybe 2 seconds.

It also fixes bugs that could have occurred in previous versions.

As 3.0.0.0 is a major overhaul of this script, all JASS scripts that depend on this need to get reinstalled.


Speed improvements
1.0.0.0

6+ hours to create 8000 objects
6+ hours to work with any objects in a map with 8000 objects​

2.0.0.0

20+ minutes to create 8000 objects
20+ minutes to work with any objects in a map with 8000 objects​

3.0.0.0

1.5 minutes to create 8000 objects
2 seconds to work with any objects in a map with 8000 objects​


Hopefully 3.0.0.0 is the final version for back-end (meaning scripts won't need to be reinstalled anymore).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
1.0.0.0


6+ hours to create 8000 objects
6+ hours to work with any objects in a map with 8000 objects

2.0.0.0


20+ minutes to create 8000 objects
20+ minutes to work with any objects in a map with 8000 objects

Version 1.0.0 must have been disgustingly slow if it took 6+ hours to create 8000 objects.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Version 1.0.0 must have been disgustingly slow if it took 6+ hours to create 8000 objects.

Nop, it was coded the same way a lot of people at wc3c do things. Are you trying to tell me that their stuff is disgustingly slow?! Parish the thought!

2.0.0.0 was coded more like how TH might have done it (a bit above and beyond for them)

3 was coded like how I'd do it. I normally coded very slack if it's not JASS, but with this I saw that I had to optimize the hell out of it regardless :\.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I don't want to comment on what I think about the wc3c.net community, but I just find it astonishing how you can go from 1 object per 2.7 seconds to roughly 120 objects per 2.7 seconds.That seems like an enormous leap in time frame - you must have had to restructure the entire thing to achieve that speed increment.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I don't want to comment on what I think about the wc3c.net community, but I just find it astonishing how you can go from 1 object per 2.7 seconds to roughly 120 objects per 2.7 seconds.That seems like an enormous leap in time frame - you must have had to restructure the entire thing to achieve that speed increment.

I certainly did. the first version number for me means a complete rewrite of the entire script =). This means that I rewrote it 3 times.
 
Top