1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  3. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  4. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Snippet] LUA_GET_VAR_OBJECT

Discussion in 'Graveyard' started by Nestharus, Dec 28, 2010.

  1. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    This resource has moved here.

    --

    gone
     
    Last edited by a moderator: Jan 17, 2018
  2. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,946
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    I definitely recommend just cp all these into one thread so people can see the full picture all on one page.
     
  3. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    That would be silly. You already know what I plan to do.

    Furthermore, this script can be improved (see note in GLOBALS thread), and I plan to make that improvement. As it stands, right now this script can bug.
     
  4. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Updated to fix a bug apparent in certain situations

    ->
    Code (vJASS):

                //! 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.
     
  5. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Updated
     
  6. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    GetVarObject 2.0 with an extended API >: D

    Code (vJASS):

    //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.
     
  7. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Updated and fixed a bug that was introduced in 2.0.0.0 ;D.
     
  8. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    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
    Code (vJASS):

    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)
    Code (vJASS):

        //! 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
     
     
  9. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    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

    Hopefully 3.0.0.0 is the final version for back-end (meaning scripts won't need to be reinstalled anymore).
     
  10. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Performed some hot fixes to 3.0.0.5

    No need to reinstall scripts, but if you are getting errors (hot fixes fixed), then you'll have to ; (.
     
  11. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Version 1.0.0 must have been disgustingly slow if it took 6+ hours to create 8000 objects.
     
  12. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    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 :\.
     
  13. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    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.
     
  14. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    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.
     
  15. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    It's astonishing except for the fact that the first one was horridly slow.
     
  16. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,427
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Hmmm...
    Code (vJASS):
    //! i createobject("Amls",generateid("Amls"))
     
  17. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
  18. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,427
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Doesn't that do the same thing?
     
  19. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    nop

    read getobjectid to learn why it doesn't do it #1
    read details on this to learn why it doesn't do it #2