A JASS function giving a strange problem

Grurf

Ultra Cool Member
Reaction score
30
What is wrong with this piece of JASS:

Code:
function SotEA_Actions takes nothing returns nothing
    local location targetloc = Location( 0.0, 0.0 )
    call RemoveLocation( targetloc )
    local effect castPoint = AddSpecialEffect( "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl", 0.0, 0.0 )
endfunction

I started with a big trigger, then isolated the problem to this. The compiler gives the error "Expected a code statement" on the line with the special effect. Some things you might want to know:

1. If I take away the "call RemoveLocation( targetloc )" it compiles fine.
2. Changing the variable names doesn't make a difference.
3. Removing other local locations (in other functions) doesn't give any problems.
4. Any trigger gives the same error if this function is inside it.
 
B

BlizzScripts

Guest
remenber first locals
Code:
function SotEA_Actions takes nothing returns nothing
    local location targetloc = Location( 0.0, 0.0 )
    local effect castPoint = AddSpecialEffect( "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl", 0.0, 0.0 )
    call RemoveLocation( targetloc )
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
The reason for this is that you declare a new local after the call RemoveLocation. So this will work:

Code:
function SotEA_Actions takes nothing returns nothing
    local location targetloc = Location( 0.0, 0.0 )
    local effect castPoint = AddSpecialEffect( "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl", 0.0, 0.0 )
    call RemoveLocation( targetloc )
endfunction

[Edit] 2 place... but this is still usefull:[/Edit]

But why do you want to create a location and instanlty remove it?
If you dont use that Location( 0.0, 0.0 ) somewhere its better to have
local location targetloc
or
local location targetloc = null
 

Grurf

Ultra Cool Member
Reaction score
30
As said, I isolated the problem. In the real function, the location is used to set X and Y reals.
 

Grurf

Ultra Cool Member
Reaction score
30
Ok, a new problem. I tried implementing handle vars into my map, but nothing is stored. I think it's my game cache. This trigger should test handle vars correctly right?

Code:
function Lol takes nothing returns nothing
    local timer t=GetExpiredTimer()
    call DisplayTextToForce(GetPlayersAll(),I2S(GetHandleInt(t,"steps")))
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t=null
endfunction

function Trig_Handle_Variables_Test_Actions takes nothing returns nothing
    local timer t=CreateTimer()
    call SetHandleInt(t, "steps", 3)
    call TimerStart(t, 1.0, false, function Lol)
    set t=null
endfunction

//===========================================================================
function InitTrig_Handle_Variables_Test takes nothing returns nothing
    set gg_trg_Handle_Variables_Test = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Handle_Variables_Test, Player(0) )
    call TriggerAddAction( gg_trg_Handle_Variables_Test, function Trig_Handle_Variables_Test_Actions )
endfunction

Well, the above trigger returns 0, indicating that the integer isn't set.

The game cache is an empty variable. Should I set it to something? A w3v file?
 
B

BlizzScripts

Guest
Code:
call DisplayTextToForce(GetPlayersAll(),I2S(GetHandleInt(t,"steps")))
You cannot Convert to integer:
 

Grurf

Ultra Cool Member
Reaction score
30
But doesn't I2S convert an integer to a string then? Because it messages 0 in-game.
 
B

BlizzScripts

Guest
try convert before put it like this:
Code:
function Lol takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string C = I2S(GetHandleInt(t,"steps"))
    call DisplayTextToForce(GetPlayersAll(), C )
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t=null
endfunction
 

Grurf

Ultra Cool Member
Reaction score
30
Ehm... I don't think the I2S is the problem. Strings and special effects won't be transferred, too.
 
B

BlizzScripts

Guest
do you have the function "GetHandleInt" in your script code?
:by the way grurf are u american?
which one of those is right?
The Soul of Apocalyspe
or
The Apocalyspe's Soul
or
The Soul's of Apocalyspe
thanks :)
 

Grurf

Ultra Cool Member
Reaction score
30
This is in my custom script section:

Code:
// ===========================
function H2I takes handle h returns integer
    return h
    return 0
endfunction

// ===========================
function LocalVars takes nothing returns gamecache
    // Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
    return udg_HandleCache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

Edit:

The Soul of the Apocalypse is the best one, the Apocalypse's Soul is ok, too, but sounds a little weird. I am no American, though, I'm Dutch.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Just becuse you created a gamecache variable it doesnt mean that there is a gamecache object connected to it

Have this at you map init

Code:
set udg_HandleCache = InitGameCache("phyrex1an")

It will not work if you put anything else than "phyrex1an" :p naa just joking the important is that there is a string as argument. If the map is a single player map i suggest that you have this insteed:
Code:
call FlushGameCache(InitGameCache("phyrex1an"))
set udg_HandleCache = InitGameCache("phyrex1an")
 
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