HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

DataSystem--Use Global arrays to Replace GameCache

07-09-2007, 02:18 AM#1
hldzhuzhu
this system can be used like UnitUserData.
We know,unit or item has UserData,that is a integer.But can we do more?
sure.Here We hava 10 integer userdatas,10 unit userdatas,10 handle userdatas,5 real userdatas,
5 boolean userdatas, for Unit,Timer and Trigger.
Sounds like GameCache,But i use global arrays to make it.so it runs faster.
in UnitData,i use UnitUserData=array index.
in TimerData,i use H2I(timer)-Start=array index
but in TriggerData,some thing new.


you can use my system like below.
Collapse JASS:
//===========================================
function echo takes nothing returns nothing
      local TimerData         td
      local UnitData          ud
      local texttag            tg
      set    td=TimerData.GetExpired()


      set    ud=UnitData.Create(td.GetUnit(0))

    
      set      tg=H2Tg(ud.GetHandle(0))
      if(tg!=null)    then
                   call   DestroyTextTag(tg)
      endif
      

      if   ( R2I(GetUnitX(ud.data))==ud.GetInteger(0)   and   R2I(GetUnitY(ud.data))==ud.GetInteger(1)   ) then

               set   tg=UnitMessage(ud.data,"stop")

               call td.Destroy()
               call ud.Destroy()
               return
      endif

      call   ud.SetInteger(0,R2I(GetUnitX(ud.data)))
      call   ud.SetInteger(1,R2I(GetUnitY(ud.data)))

      set    tg=UnitMessage(td.GetUnit(0),"|cffff0000X: |r"+I2S(ud.GetInteger(0))+"|cffff0000Y: |r"+I2S(ud.GetInteger(1)))
      call   ud.SetHandle(0,tg)
endfunction

function Trig_echo_unit_Actions takes nothing returns nothing
      local unit          u=       GetTriggerUnit()
      local UnitData    ud
      local TimerData td
 
   
      if(UnitData.HasData(u) ) then
             return
      endif
    call    UnitMessage(u,"select")
      set      ud=UnitData.Create(u)
      set      td=TimerData.Run(1,true,function echo)
      call    td.SetUnit(0,u)
endfunction

thanks Vexorian,for Vjass
thsnks zoxc ,for WeHelper.
Attached Files
File type: w3xDataSystem.w3x (99.2 KB)
07-09-2007, 03:35 AM#2
Pyrogasm
If you need vJASS to use this system... why not just use structs?
07-09-2007, 03:51 AM#3
hldzhuzhu
I don't known what's your means.
the scripts i post just about how to use the system,not the system.

well,I use structs,don't you see?
07-09-2007, 05:21 AM#4
Here-b-Trollz
Brush please on up your English. Anyway, what Pyro is saying is that this is rather simple, and that most of the beauty of your system is in the system that it uses (structs), not in the coding you did yourself. It is nice though (maybe the terrible spacing issues could be corrected?)
07-09-2007, 06:57 AM#5
hldzhuzhu
well,
if i give a number,1048668,
can you create a trigger Trg_test,
and make: H2I(Trg_test)==1048668
Collapse JASS:
local trigger  Trg_test
//.........do something
H2I(Trg_test)==1048668
and that is what my system is about.
07-09-2007, 07:02 AM#6
Toadcop
hldzhuzhu well to be true... it's nothing new =) so it's awesome what you maked this system but i would say the best would be if you use it for your self ^^.