- Joined
- Jul 10, 2007
- Messages
- 6,306
set w = w + 1
set catalog = w
set l[w] = w
set p[w] = w
set i[w] = Table.create()
set r[w] = Table.create()
set f[w] = Table.create()
struct tester extends array
private static method onInit takes nothing returns nothing
local integer c1 = CatalogCreate()
local integer c2 = CatalogCreate()
local integer c3 = CatalogCreate()
local integer c4 = CatalogCreate()
call CatalogAddCatalog(c4,c3)
call CatalogAddCatalog(c3,c2)
call CatalogAddCatalog(c2,c1)
call CatalogAdd(c1, 'hrif')
call CatalogAdd(c2, 'Hpal')
call CatalogAdd(c1, 'hpea')
call CatalogAdd(c3, 'hfoo')
call CatalogAdd(c4, 'hsor')
//hsor: 1
//hpea: 2
//hfoo: 3
//Hpal: 4
//hrif: 5
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hsor')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hpea')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hfoo')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'Hpal')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hrif')))
endmethod
endstruct
struct tester extends array
private static method onInit takes nothing returns nothing
local integer c1 = CatalogCreate()
local integer c2 = CatalogCreate()
local integer c3 = CatalogCreate()
local integer c4 = CatalogCreate()
call CatalogAddCatalog(c4,c3)
call CatalogAddCatalog(c3,c2)
call CatalogAddCatalog(c2,c1)
call CatalogAdd(c1, 'hrif')
call CatalogAdd(c1, 'hpea')
call CatalogAdd(c2, 'Hpal')
call CatalogAdd(c2, 'hpea')
call CatalogAdd(c3, 'hpea')
call CatalogAdd(c3, 'hfoo')
call CatalogAdd(c4, 'hsor')
//hsor: 1
//hpea: 2
//hfoo: 3
//Hpal: 4
//hrif: 6
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hsor')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hpea')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hfoo')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'Hpal')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hrif')))
endmethod
endstruct
function SpeedUpHashtable takes hashtable h returns nothing
call SaveInteger(h, 2146689309, -34, 0)
endfunction
function SpeedUpTable takes Table tb returns nothing
set tb[-2146689309] = 0
endfunction
struct testers extends array
private static hashtable table = InitHashtable()
private static method onInit takes nothing returns nothing
call LoadInteger(table, 0, 0)
if (HaveSavedInteger(table, 0, 0)) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Saved")
else
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Not Saved")
endif
endmethod
endstruct
struct testers extends array
private static method onInit takes nothing returns nothing
local integer c1 = CatalogCreate()
local integer c2 = CatalogCreate()
local integer c3 = CatalogCreate()
local integer c4 = CatalogCreate()
call CatalogAddCatalog(c4,c3)
call CatalogAddCatalog(c3,c2)
call CatalogAddCatalog(c2,c1)
call CatalogAdd(c1, 'hrif')
call CatalogAdd(c2, 'Hpal')
call CatalogAdd(c3, 'hpea')
call CatalogAdd(c3, 'hfoo')
call CatalogAdd(c4, 'hsor')
//hsor: 1
//hpea: 2
//hfoo: 3
//Hpal: 4
//hrif: 5
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogRaw(c4, 1))+"=="+I2S('hsor'))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogRaw(c4, 2))+"=="+I2S( 'hpea'))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogRaw(c4, 3))+"=="+I2S( 'hfoo'))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogRaw(c4, 4))+"=="+I2S( 'Hpal'))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogRaw(c4, 5))+"=="+I2S( 'hrif'))
/*call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hsor')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hpea')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hfoo')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'Hpal')))
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogId(c4, 'hrif')))*/
call CatalogDestroy(c2)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,I2S(CatalogCount(c4)))
endmethod
endstruct
struct testers extends array
private static method Count takes integer n returns integer
return n*(n+1)/2
endmethod
private static method init takes nothing returns nothing
local Catalog c1 = Catalog.create()
local Catalog c2 = Catalog.create()
local Catalog c3 = Catalog.create()
local Catalog c4 = Catalog.create()
local Catalog c5 = Catalog.create()
local Catalog c6 = Catalog.create()
local Catalog c7 = Catalog.create()
local Catalog c8 = Catalog.create()
call c8.addCatalog(c7)
call c8.addCatalog(c6)
call c7.addCatalog(c6)
call c7.addCatalog(c6)
call c6.addCatalog(c5)
call c6.addCatalog(c4)
call c5.addCatalog(c4)
call c5.addCatalog(c3)
call c4.addCatalog(c3)
call c4.addCatalog(c2)
call c2.addCatalog(c1)
call c1.addCatalog(c8)
call c1.add(-1)
call c2.add(-2)
call c2.add(-3)
call c3.add(-4)
call c3.add(-5)
call c3.add(-6)
call c4.add(-7)
call c4.add(-8)
call c4.add(-9)
call c4.add(-10)
call c5.add(-11)
call c5.add(-12)
call c5.add(-13)
call c5.add(-14)
call c5.add(-15)
call c6.add(-16)
call c6.add(-17)
call c6.add(-18)
call c6.add(-19)
call c6.add(-20)
call c6.add(-21)
call c7.add(-22)
call c7.add(-23)
call c7.add(-24)
call c7.add(-25)
call c7.add(-26)
call c7.add(-27)
call c7.add(-28)
call c8.add(-29)
call c8.add(-30)
call c8.add(-31)
call c8.add(-32)
call c8.add(-33)
call c8.add(-34)
call c8.add(-35)
call c8.add(-36)
/*
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.raw(36))+"=="+I2S(-1))
call c7.destroy()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.raw(36-7))+"=="+I2S(-1))
*/
/*
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.id(-1))+"=="+I2S(36-7))
call c7.destroy()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.id(-1))+"=="+I2S(36-7))
*/
/*
call c4.destroy()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.count)+"=="+I2S(Count(8)-4-2-1))
call c5.destroy()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,6000,I2S(c8.count)+"=="+I2S(Count(8)-5-4-3-2-1))
*/
call DestroyTimer(GetExpiredTimer())
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function thistype.init)
endmethod
endstruct
struct Tester extends array
private static method onInit takes nothing returns nothing
local Catalog c = Catalog.create()
local Catalog c2 = Catalog.create()
local Catalog c3 = Catalog.create()
local Catalog c4 = Catalog.create()
local Catalog c5 = Catalog.create()
local CatalogLoop catalogLoop
local integer value
call c.addCatalog(c2)
call c.addCatalog(c3)
call c3.addCatalog(c4)
call c4.addCatalog(c5)
call c.add(1)
call c.add(2)
call c2.add(3)
call c2.add(4)
call c5.add(7)
set catalogLoop = CatalogLoop.create(c, 1)
loop
set value = catalogLoop.next
exitwhen 0 == value
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Found "+I2S(value))
endloop
endmethod
endstruct
noSo CatalogLoop helps to find repeat-values in catalogs?
What does it do if they are found?