wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-03-2008, 09:08 PM   #16
Here-b-Trollz
Corkscrew Chainsaw!!!
 
Join Date: Jun 2006
Posts: 711

Here-b-Trollz has a spectacular aura about (149)

Hero Contest #2 - 2nd Place

Default

Think of Table as an integer array. However, while a normal integer array can only use indexes 0 - 8191, Table can use any integer (even negatives). If you define the table as local, it acts just like a local integer array. If you define it as global, it acts like a global integer array.

Hmm... hopefully this will help:

Expand JASS:

Call will display

1

(5 second wait)

2

1

(5 second wait)

3

__________________
By reading this signature, you agree that I cannot be held accountable for anything that I might say or do.
Here-b-Trollz is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-03-2008, 09:42 PM   #17
the-thingy
User
 
Join Date: Feb 2006
Posts: 172

the-thingy will become famous soon enough (30)the-thingy will become famous soon enough (30)

Default

Ah, I see, thanks :)

So, under 'normal' circumstances, a local Table, and a single key should do fine?

Would there be any problem with using the same key in separate triggers, if t is local to each?
the-thingy is offline   Reply With Quote
Old 07-04-2008, 07:33 PM   #18
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,074

Submissions (19)

Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by the-thingy
Ah, I see, thanks :)

So, under 'normal' circumstances, a local Table, and a single key should do fine?

Would there be any problem with using the same key in separate triggers, if t is local to each?
It doesn't matter if it's a local or global variable. What matters is that whenever you call Table.create() that gives you a new associative array, so if you create two tables in two triggers (or in one, doesn't matter) and set them to two different variables (global or local, doesn't matter) data stored to one or the other won't conflict.

BTW, Trollz, that's not what your script would actually output.
__________________
Anitarf is offline   Reply With Quote
Old 07-05-2008, 03:42 AM   #19
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

All right I updated it, it is less pure but a little better, something like this requires to cover all gamecache usage else it is not a good idea to implement it along with other gamecaches, the difference is that you can use HandleTable and StringTable to have tables with different key types.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 07-06-2008, 08:08 AM   #20
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)cohadar is a jewel in the rough (246)

Default

I think you should not use macro parameter for mission key.
Better instead pass it to a constructor.

I misread it, thought $key$ was mission and it is I2S(this), nwm

EDIT:
Why you called this table when it is only a nice way of doing gamecache?
Why not simply call it Cache?
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.

Last edited by cohadar : 07-06-2008 at 09:20 PM.
cohadar is offline   Reply With Quote
Old 08-03-2008, 12:39 AM   #21
waaaks
User
 
waaaks's Avatar
 
Join Date: Apr 2007
Posts: 356

waaaks is on a distinguished road (12)

Default

is this the same as the Table trigger inside your xe system?
__________________
waaaks is offline   Reply With Quote
Old 08-03-2008, 02:37 AM   #22
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

Table is just used by one of the xe samples, it is not part of xe.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 08-03-2008, 08:17 AM   #23
waaaks
User
 
waaaks's Avatar
 
Join Date: Apr 2007
Posts: 356

waaaks is on a distinguished road (12)

Default

ok, so that means this table cant be a substitute for xe's table
__________________
waaaks is offline   Reply With Quote
Old 08-03-2008, 12:37 PM   #24
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

Quote:
Originally Posted by waaaks
ok, so that means this table cant be a substitute for xe's table
It actually means the opposite. There's no such a thing as xetable.

The Table library used by stormy dreams is an old version of this thing, you can safely upgrade.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 08-11-2008, 05:12 PM   #25
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,727

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

You know, only after having Anitarf explain to me what all of the vJass stuff in this does to me did it occur to me how awesome this really is. Mad props, Vex.
__________________
Rising_Dusk is offline   Reply With Quote
Old 11-28-2008, 09:27 AM   #26
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,514

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

So, I needed a Table to store reals, and I realized that I would have to modify your library to do so. I ended up with this, and it seems to work:
Collapse JASS:
library Table initializer init
//***************************************************************
//* Table object
//* ------------
//*
//*   set t=Table.create() - instanceates a new table object
//*   call t.destroy()     - destroys it
//*   t[1234567]           - Get value for key 1234567
//*                          (zero if not assigned previously)
//*   set t[12341]=32      - Assigning it.
//*   call t.flush(12341)  - Flushes the stored value, so it
//*                          doesn't use any more memory
//*   t.exists(32)         - Was key 32 assigned? Notice
//*                          that flush() unassigns values.
//*   call t.reset()       - Flushes the whole contents of the
//*                          Table.
//*
//*   call t.destroy()     - Does reset() and also recycles the id.
//*
//*   If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//***************************************************************

//=============================================================
    globals
        private constant integer MAX_INSTANCES=8100 //400000

    //=========================================================
        private gamecache gc
    endglobals

    private struct GTable[MAX_INSTANCES]
        method reset takes nothing returns nothing
            call FlushStoredMission(gc,I2S(this))
        endmethod

        private method onDestroy takes nothing returns nothing
            call FlushStoredMission(gc,I2S(this))
        endmethod
    endstruct

    //Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
    //! textmacro Table__make takes name, type, key
    struct $name$ extends GTable

        method operator [] takes $type$ key returns integer
            return GetStoredInteger(gc,I2S(this),$key$)
        endmethod

        method operator []= takes $type$ key, integer value returns nothing
            call StoreInteger(gc,I2S(this),$key$, value)
        endmethod

        method flush takes $type$ key returns nothing
            call FlushStoredInteger(gc,I2S(this),$key$)
        endmethod

        method exists takes $type$ key returns boolean
            return HaveStoredInteger(gc,I2S(this),$key$)
        endmethod

    endstruct
    //! endtextmacro



    private function H2I takes handle h returns integer
        return h
        return 0
    endfunction
    
    //! runtextmacro Table__make("Table","integer","I2S(key)" )
    //! runtextmacro Table__make("StringTable","string","key" )
    //! runtextmacro Table__make("HandleTable","handle","I2S(H2I(key))" )

    //Pyrogasm Stuff:
    struct RealTable extends GTable

        method operator [] takes real key returns real
            return GetStoredReal(gc,I2S(this),R2S(key))
        endmethod

        method operator []= takes real key, real value returns nothing
            call StoreReal(gc,I2S(this),R2S(key), value)
        endmethod

        method flush takes real key returns nothing
            call FlushStoredReal(gc,I2S(this),R2S(key))
        endmethod

        method exists takes real key returns boolean
            return HaveStoredReal(gc,I2S(this),R2S(key))
        endmethod

    endstruct

    //=============================================================
    // initialize it all.
    //
    private function init takes nothing returns nothing
        call FlushGameCache(InitGameCache("libtable.gc"))
        set gc=InitGameCache("libtable.gc")
    endfunction
endlibrary

But anyway: I think that you should add a "RealTable" to this, as it is potentially useful to others, let alone myself.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 11-28-2008, 11:53 PM   #27
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

I never thought of that mostly because storing anything other than integer is kind of lame?

What's that odd situation in which you ONLY need a real value and nothing integral?
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 11-29-2008, 01:14 AM   #28
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)Ammorth is a glorious beacon of light (457)

Default

I agree that storing anything other than an integer is lame (cause you should be using structs for handles) but I also needed a RealTable for one of my systems.

I wanted to use it for storing the widths of chars, and storing as an integer and dividing by some constant seemed like a waste of over-head.
__________________
Ammorth is offline   Reply With Quote
Old 11-29-2008, 07:40 AM   #29
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,514

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

I used it for storing Weights in my Pools library.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 12-01-2008, 08:12 PM   #30
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,074

Submissions (19)

Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Ammorth
I wanted to use it for storing the widths of chars, and storing as an integer and dividing by some constant seemed like a waste of over-head.
I had the exact same situation when converting the subtitle engine of my cinematic system into a stand-alone library, I saw no problem in just storing integers; the gamecache use alone makes division by a constant insignificant, especially if you don't do it for every character but only for the final sum of widths. There is really no need for a real table.
__________________
Anitarf is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:23 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services