Reading from SLK tables

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
I've managed to use some of that bad ass LUA scripting and generate an SLK table from it. But I don't really understand how to read a SLK table in vJass.
There is little to find on how the SLK tables work, and the only example which I could find on the Internet is the one from JassHelperManual.
However, that example is broken and doesn't seem to work for me.
Can someone throw me a bone here?

JASS:
library fooooo

    //! loaddata baarrrrr.slk

    struct meh
        static thistype array values
        public string         title
        public string         icon
        public string         question
        public string         answer
        public integer        points
        public integer        category
        public integer        difficulty
        public boolean        active

        static method getFromKey takes integer i returns thistype
            if ( .values<i> != 0 ) then
                set .values<i> = thistype.create()
            endif
            return .values<i>
        endmethod

        static method onInit takes nothing returns nothing
            local integer i = 0
            loop
                call BJDebugMsg( .getFromKey(i).title )
                set i = i + 1
                exitwhen i &gt; 12
            endloop
        endmethod
    endstruct
    
endlibrary</i></i></i>


And here is the SLK table:
Code:
ID;PSCALC3
C;X1;Y1;K"meh"
C;X2;Y1;K"title"
C;X3;Y1;K"icon"
C;X4;Y1;K"question"
C;X5;Y1;K"answer"
C;X6;Y1;K"points"
C;X7;Y1;K"category"
C;X8;Y1;K"difficulty"
C;X9;Y1;K"active"
C;X1;Y2;K1
C;X2;Y2;K"titel"
C;X3;Y2;K"Icoon"
C;X4;Y2;K"Vraag"
C;X5;Y2;K"antwoord"
C;X6;Y2;K1
C;X7;Y2;K1
C;X8;Y2;K1
C;X9;Y2;K1
E

All it does is display (null), while this is directly from the manual with a code fix. Because in the manual it's returns nothing.
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
Never mind, I figured it out. The problem was that the SLK table was initialized after the struct onInit. I personally think SLK tables should be initialized before everything, but oh well..
If anyone wants to do the same thing, this seems to do the trick.

JASS:
library fooooo initializer init

    //! loaddata baarrrrr.slk

    struct meh
        public string         title
        public string         icon
        public string         question
        public string         answer
        public integer        points
        public integer        category
        public integer        difficulty
        public boolean        active

        static method getFromKey takes integer i returns thistype
            return thistype(i)
        endmethod
    endstruct
    
    private function onExpire takes nothing returns nothing
        call BJDebugMsg( riddle(1).title )
    endfunction
    
    private function init takes nothing returns nothing
        call TimerStart( CreateTimer(), 1, false, function onExpire )
    endfunction
    
endlibrary
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
oh noes, is this some kind of riddle anticheat

>:x
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
Xanthius the Riddler II, yeah. I use LUA to generate the SLK table with it I can just easily add questions and answers and other sorts of stuff. Then LUA automatically converts answers, with a random charmap each time.

Since I don't use an decryption function it's a pretty neat way to hide answers in the War3map.j
The previous map was pretty lame I believe, that is if you can remember the first.

LUA is an awesome way to do this, might write a tutorial about it too.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top