HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help with a loop function

11-11-2006, 12:44 PM#1
RaveEye
Hi w3c.

Im new to jass, and I have some truble with
the loop function, its like it dosent loop.

This function run when you use an item.
iid = Is the manipulated item
Collapse JASS:
function check_index takes integer iid returns nothing
local integer loopx = 1
local integer loopy = 5    
loop
    set loopx = loopx + 1
    exitwhen loopx > loopy     
if ( not ( iid == GetStoredInteger(udg_gc, ( "itemlist" + I2S(loopx) ), "integer") ) ) then
    call StoreInteger(udg_gc, "index", "integer", loopx)
    call DisplayTextToForce( GetPlayersAll(), ( "itemlist" + I2S(loopx) ) )
endif
endloop
    call DisplayTextToForce( GetPlayersAll(), I2S(GetStoredInteger(udg_gc, "index", "integer")) ) 
endfunction

And the data stored in a game cache.

Collapse JASS:
function setup_gamecache takes nothing returns nothing
    call InitGameCache("EQVA")
    set udg_gc = GetLastCreatedGameCacheBJ()
    call StoreInteger(udg_gc, "itemlist1", "integer", 'I000')
    call StoreInteger(udg_gc, "itemlist2", "integer", 'I001')
    call StoreInteger(udg_gc, "itemlist3", "integer", 'I002')
    call StoreInteger(udg_gc, "itemlist4", "integer", 'I003')
    call StoreInteger(udg_gc, "itemlist5", "integer", 'I004')
endfunction
11-11-2006, 01:32 PM#2
Fireeye
how about removing the not and the ()?
Collapse JASS:
if iid == GetStoredInteger(udg_gc, "itemlist" + I2S(loopx), "integer") then
11-13-2006, 01:10 PM#3
RaveEye
It dosent work. When I try to save the map, it gives me a error.
11-13-2006, 02:59 PM#4
The)TideHunter(
Well we cant help you if we dont know what it is!
Give us more infomation, what line does it say its on and what does the error say?
11-13-2006, 03:43 PM#5
Captain Griffen
Collapse JASS:
    call InitGameCache("EQVA")
    set udg_gc = GetLastCreatedGameCacheBJ()

Won't work.

Collapse JASS:
    set udg_gc = InitGameCache("EQVA.w3v")

Will.

Also missing an endfunction on the first func.
11-14-2006, 02:50 PM#6
The)TideHunter(
Quote:
Originally Posted by Captain Griffen
Collapse JASS:
    set udg_gc = InitGameCache("EQVA.w3v")

Will.

Also missing an endfunction on the first func.

No need for the ".w3v". Anything will do.
Unless its for a campaign, then i think you need it.
11-14-2006, 03:43 PM#7
Captain Griffen
Main thing was that GetLastCreatedGameCacheBJ() isn't set by natives, only by BJs.