Convert this Code to 1.24

Silencer

New Member
Reaction score
0
How to convert this code to 1.24b ?

JASS:
function SHHandle takes handle s, string n, handle v returns nothing
    if v==null then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, H2I(v))
    endif
endfunction
function SHInt takes handle s, string n, integer v returns nothing
    if v==0 then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHBoolean takes handle s, string n, boolean v returns nothing
    if v==false then
        call FlushStoredBoolean(udg_cache,I2S(H2I(s)),n)
    else
        call StoreBoolean(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHReal takes handle s, string n, real v returns nothing
    if v==0 then
        call FlushStoredReal(udg_cache, I2S(H2I(s)), n)
    else
        call StoreReal(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHString takes handle s, string n, string v returns nothing
    if v==null then
        call FlushStoredString(udg_cache, I2S(H2I(s)), n)
    else
        call StoreString(udg_cache, I2S(H2I(s)), n, v)
    endif
function GHBoolean takes handle s, string n returns boolean
    return GetStoredBoolean(udg_cache, I2S(H2I(s)), n)
endfunction
function GHReal takes handle s, string n returns real
    return GetStoredReal(udg_cache, I2S(H2I(s)), n)
endfunction
function GHUnit takes handle s, string n returns unit
    return GetStoredInteger(udg_cache, I2S(H2I(s)), n)
    return null
endfunction
function FHLocals takes handle s returns nothing
    call FlushStoredMission(udg_cache, I2S(H2I(s)) )
endfunction
function RemoveUnitTimed takes unit u, real dur returns nothing
    call RemoveTimedEnum.execute(u,dur)
endfunction
function TimedEffectPt takes real x, real y, real duration, string efx returns nothing
    local effect fx = AddSpecialEffect(efx, x, y)
    local timer t = CreateTimer()
    call SHHandle(t, "fx", fx)
    call TimerStart(t, duration, false, function EffectDestroy)
    set t = null
    set fx = null
endfunction

function SETRemove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GHUnit(t,"u")
    local string s = GHString(t,"s")
    call SHBoolean(u,s,false)
    call FHLocals(t)
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction


Also i get a jass error (syntax error, unexspected "takes" ?) here and i dont know why =/

JASS:
function GHBoolean takes handle s, string n returns boolean
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Here you go :
JASS:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
function SHHandle takes handle s, string n, handle v returns nothing
    if v==null then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, H2I(v))
    endif
endfunction
function SHInt takes handle s, string n, integer v returns nothing
    if v==0 then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHBoolean takes handle s, string n, boolean v returns nothing
    if v==false then
        call FlushStoredBoolean(udg_cache,I2S(H2I(s)),n)
    else
        call StoreBoolean(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHReal takes handle s, string n, real v returns nothing
    if v==0 then
        call FlushStoredReal(udg_cache, I2S(H2I(s)), n)
    else
        call StoreReal(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHString takes handle s, string n, string v returns nothing
    if v==null then
        call FlushStoredString(udg_cache, I2S(H2I(s)), n)
    else
        call StoreString(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function GHBoolean takes handle s, string n returns boolean
    return GetStoredBoolean(udg_cache, I2S(H2I(s)), n)
endfunction
function GHReal takes handle s, string n returns real
    return GetStoredReal(udg_cache, I2S(H2I(s)), n)
endfunction
function I2I takes integer i returns integer
    return i
endfunction
function GHUnit takes handle s, string n returns unit
    call I2I(GetStoredInteger(udg_cache, I2S(H2I(s)), n))
    if false then
        return null
    endif
endfunction
function FHLocals takes handle s returns nothing
    call FlushStoredMission(udg_cache, I2S(H2I(s)) )
endfunction
function RemoveUnitTimed takes unit u, real dur returns nothing
    call RemoveTimedEnum.execute(u,dur)
endfunction
function TimedEffectPt takes real x, real y, real duration, string efx returns nothing
    local effect fx = AddSpecialEffect(efx, x, y)
    local timer t = CreateTimer()
    call SHHandle(t, "fx", fx)
    call TimerStart(t, duration, false, function EffectDestroy)
    set t = null
    set fx = null
endfunction

function SETRemove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GHUnit(t,"u")
    local string s = GHString(t,"s")
    call SHBoolean(u,s,false)
    call FHLocals(t)
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction
 

Silencer

New Member
Reaction score
0
Have you a tool to convert? Or do it by hand?

JASS:
function GHTrigger takes handle s, string n returns trigger
    return GetStoredInteger(udg_cache, I2S(H2I(s)), n)
    if false then
        return null
    endif
endfunction


Jass tell me that it misses a "return" ?! Dont know if it is that... but the map is still unplayable and this is the only JASS trigger in there.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Hashtable version :
JASS:
library HandleVars
    globals
        private hashtable udg_cache = InitHashtable()
    endglobals
    
    //! textmacro HANDLE_VARS takes NAME, FUNCTION, TYPE, NULL_VALUE
    function SH$NAME$ takes handle s, string n, $TYPE$ v returns nothing
        if v==$NULL_VALUE$ then
            call RemoveSaved$NAME$(udg_cache,GetHandleId(s),StringHash(n))
        else
            call Save$FUNCTION$(udg_cache, GetHandleId(s), StringHash(n), v)
        endif
    endfunction
    //! endtextmacro
    //! runtextmacro HANDLE_VARS ("Handle", "AgentHandle", "agent", "null")
    //! runtextmacro HANDLE_VARS ("Integer", "Integer", "integer", "0")
    //! runtextmacro HANDLE_VARS ("Real", "Real", "real", "0.")
    //! runtextmacro HANDLE_VARS ("Boolean", "Boolean", "boolean", "false")
    //! runtextmacro HANDLE_VARS ("String", "Str", "string", "null")
    
    //! textmacro HANDLE_VARS_GET takes TYPE, FUNC, type
    function GetH$TYPE$ takes handle s, string n returns $type$
        return Load$FUNC$(udg_cache,GetHandleId(s),StringHash(n))
    endfunction
    //! endtextmacro
    //! runtextmacro HANDLE_VARS_GET ("Integer","Integer","integer")
    //! runtextmacro HANDLE_VARS_GET ("Real","Real","real")
    //! runtextmacro HANDLE_VARS_GET ("Boolean","Boolean","boolean")
    //! runtextmacro HANDLE_VARS_GET ("String","Str","string")
    
    //! textmacro HANDLE_VARS_GETHANDLE takes TYPE, type
    function GH$TYPE$ takes handle s, string n returns $type$
        return Load$TYPE$Handle(udg_cache,GetHandleId(s),StringHash(n))
    endfunction
    //! endtextmacro 
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Unit","unit")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Effect","effect")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Lightning","lightning")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Location","location")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Trigger","trigger")
        //! runtextmacro HANDLE_VARS_GETHANDLE ("Timer","timer")
    
    function FHLocals takes handle s returns nothing
        call FlushChildHashtable(udg_cache,GetHandleId(s))
    endfunction
endlibrary
 

Silencer

New Member
Reaction score
0
Hm missing "return" again. Here is a screenshot:

n5q5n7.jpg
 

Silencer

New Member
Reaction score
0
I used your version with
Code:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
at the beginning, is right or?
 

Silencer

New Member
Reaction score
0
Well i used it but i get as i said the "missing return" error... and with that i cant play the map. Any suggestions?
 

Silencer

New Member
Reaction score
0
But your hashtable version not contain the full code and i dont know how to build the rest =(
If i replace it, i will get many errors about missing variables...

Now i would be happy if i can write jass, its just these small spell that ruins my hole map, but i need it -.-

Can you take a look on it please? I add the spell below
 

Attachments

  • testmap.w3x
    22.9 KB · Views: 206

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
Hashtable version :
<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"><div class="bbCodeBlock-title">JASS:</div><div class="bbCodeBlock-content"><pre class="bbCodeCode"><code class="jass"><span class="keyword">library</span> <span>HandleVars</span>
    <span class="keyword">globals</span>
        <span class="keyword">private</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/hashtable" class="type">hashtable</a> <span>udg_cache</span> <span class="symbol">=</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/InitHashtable" class="native">InitHashtable</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">endglobals</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS takes NAME, FUNCTION, TYPE, NULL_VALUE</span>
    <span class="keyword">function</span> <span>SH</span>$<span>NAME</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span><span class="symbol">,</span> $<span>TYPE</span>$ <span>v</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
        <span class="keyword">if</span> <span>v</span><span class="symbol">=</span><span class="symbol">=</span>$<span>NULL_VALUE</span>$ <span class="keyword">then</span>
            <span class="keyword">call</span> <span>RemoveSaved</span>$<span>NAME</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
        <span class="keyword">else</span>
            <span class="keyword">call</span> <span>Save</span>$<span>FUNCTION</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">,</span> <span>v</span><span class="symbol">)</span>
        <span class="keyword">endif</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Handle&amp;quot;, &amp;quot;AgentHandle&amp;quot;, &amp;quot;agent&amp;quot;, &amp;quot;null&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Integer&amp;quot;, &amp;quot;Integer&amp;quot;, &amp;quot;integer&amp;quot;, &amp;quot;0&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Real&amp;quot;, &amp;quot;Real&amp;quot;, &amp;quot;real&amp;quot;, &amp;quot;0.&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Boolean&amp;quot;, &amp;quot;Boolean&amp;quot;, &amp;quot;boolean&amp;quot;, &amp;quot;false&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;String&amp;quot;, &amp;quot;Str&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;null&amp;quot;)</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS_GET takes TYPE, FUNC, type</span>
    <span class="keyword">function</span> <span>GH</span>$<span>TYPE</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span> <span class="keyword">returns</span> $<span class="keyword">type</span>$
        <span class="keyword">return</span> <span>Load</span>$<span>FUNC</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Integer&amp;quot;,&amp;quot;Integer&amp;quot;,&amp;quot;integer&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Real&amp;quot;,&amp;quot;Real&amp;quot;,&amp;quot;real&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Boolean&amp;quot;,&amp;quot;Boolean&amp;quot;,&amp;quot;boolean&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;String&amp;quot;,&amp;quot;Str&amp;quot;,&amp;quot;string&amp;quot;)</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS_GETHANDLE takes TYPE, type</span>
    <span class="keyword">function</span> <span>GH</span>$<span>TYPE</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span> <span class="keyword">returns</span> $<span class="keyword">type</span>$
        <span class="keyword">return</span> <span>Load</span>$<span>TYPE</span>$<span>Handle</span><span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro </span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Unit&amp;quot;,&amp;quot;unit&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Effect&amp;quot;,&amp;quot;effect&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Lightning&amp;quot;,&amp;quot;lightning&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Location&amp;quot;,&amp;quot;location&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Trigger&amp;quot;,&amp;quot;trigger&amp;quot;)</span>
        <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Timer&amp;quot;,&amp;quot;timer&amp;quot;)</span>
    
    <span class="keyword">function</span> <span>FHLocals</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
        <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/FlushChildHashtable" class="native">FlushChildHashtable</a><span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
<span class="keyword">endlibrary</span></code></pre></div></div>

Use this, sorry. Typo for the functions&#039; name.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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