HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Another question

08-13-2007, 04:10 AM#1
burningice95
Edit: Problem solved.
08-13-2007, 08:08 AM#2
Silvenon
I haven't read all of this, but did you make sure that you have a global variable named 'cache' of type 'game cache'? Another tip, in LocalVars function it's better to have a map initialization trigger that does:

Collapse JASS:
call FlushGameCache(InitGameCache("cache"))
set udg_cache = InitGameCache("cache")

Then change LocalVars function into this:

Collapse JASS:
function LocalVars takes nothing returns gamecache
    return udg_cache
endfunction

So it doesn't always have check if udg_cache is null every time you store something. Oh, and if you're gonna be jasser, learn vJass as soon as possible, it will save you a lot of space and it's not complicated.
08-13-2007, 05:27 PM#3
burningice95
I did what you said, and the map still wouldn't start. :(
08-13-2007, 05:34 PM#4
cohadar
Use NewGen for God's sake.
08-13-2007, 05:44 PM#5
burningice95
I do use newgen, but there is a bug with newgen & vexorians spell factory, where it finds an error in your header (and stops there, and doesn't check the rest of your code).

I'm trying importing the spell into a new map, without the spell factory to see if I can get it to work....
08-13-2007, 06:07 PM#6
cohadar
Quote:
Originally Posted by burningice95
I do use newgen, but there is a bug with newgen & vexorians spell factory, where it finds an error in your header (and stops there, and doesn't check the rest of your code).

I'm trying importing the spell into a new map, without the spell factory to see if I can get it to work....

Yes it is true you cannot use NewGen and map header at the same time.
I don't know if Vex did that on purpose but if he did I totally agree with him,
map header sux.

Besides spell factory is kind of outdated, Vex said himself that JESP is better.

And all that handle-vars functions.... really really bad idea.

I suggest you start using some new systems.
08-13-2007, 06:21 PM#7
burningice95
I'm not a JASS user...I'm just trying to import some spells :(


Anyway I had 2 versions of local handle vars in my map (one had more stuff then the other)

Version 1)

Collapse JASS:
//**************************************************************************************************
//*
//*  Handle Variables Functions
//*
//*  -------------------------------
//*  Enables the usage of game cache
//*  to transphere local variables
//*  between functions
//*  -------------------------------
//*
//*  Requires:
//*  ¯¯¯¯¯¯¯¯¯
//*  - Global variable with type "Game Cache" and name "cache"
//*    Note that this codes MUST BE PLACED BEFORE ANYTHING here.
//**************************************************************************************************

function LocalVars takes nothing returns gamecache
    if udg_cache==null then
        set udg_cache=InitGameCache("cache")
    endif
    return udg_cache
endfunction

//-------------------------------------------------

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function H2U takes handle h returns unit
    return h
    return null
endfunction

function H2E takes handle h returns effect
    return h
    return null
endfunction

function H2L takes handle h returns lightning
    return h
    return null
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 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 SetHandleHandle takes handle subject, string name,  handle value returns nothing
    call SetHandleInt( subject, name, H2I(value) )
endfunction

//-------------------------------------------------

function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction

//-------------------------------------------------

function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction


//-------------------------------------------------

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

//-------------------------------------------------

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

//-------------------------------------------------


Version 2)
Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

//==================
// Local Variables
//==================

function LocalVars takes nothing returns gamecache
    if udg_cache == null then
        call FlushGameCache(InitGameCache("lvars"))
        set udg_cache=InitGameCache("lvars")
    endif
    return udg_cache
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 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 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 GetHandlePlayer takes handle subject, string name returns player
    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 GetHandleTextTag takes handle subject, string name returns texttag
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction 

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



My merged version:
Collapse JASS:
//**************************************************************************************************
//*
//*  Handle Variables Functions
//*
//*  -------------------------------
//*  Enables the usage of game cache
//*  to transphere local variables
//*  between functions
//*  -------------------------------
//*
//*  Requires:
//*  ¯¯¯¯¯¯¯¯¯
//*  - Global variable with type "Game Cache" and name "cache"
//*    Note that this codes MUST BE PLACED BEFORE ANYTHING here.
//**************************************************************************************************

function LocalVars takes nothing returns gamecache
    if udg_cache==null then
        set udg_cache=InitGameCache("cache")
    endif
    return udg_cache
endfunction

//-------------------------------------------------

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function H2U takes handle h returns unit
    return h
    return null
endfunction

function H2E takes handle h returns effect
    return h
    return null
endfunction

function H2L takes handle h returns lightning
    return h
    return null
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 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 SetHandleHandle takes handle subject, string name,  handle value returns nothing
    call SetHandleInt( subject, name, H2I(value) )
endfunction

//-------------------------------------------------

function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction

//-------------------------------------------------

function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction


//-------------------------------------------------

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

//-------------------------------------------------

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

//-------------------------------------------------


I'm pretty sure I didn't...