• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Transferring data in structs

Status
Not open for further replies.
Level 10
Joined
Sep 21, 2007
Messages
517
How can i transfer data from one struct to another? for example, a unit channels an ability, i save a timer in struct A, and in struct B extends struct A, i call dat.destroy(), but i want the timer from struct A to be destroyed? how can i get its reference? does it have to be CS, hashtables or whatnot or can this be done in structs too? (im pretty sure its can, im just bad at OOP and JASS)
 
child structs have access to all (non private) variables and methods of its parent so if B is really a child of A theres no need to "transfer" anything as you just could do B.unit when unit is a variable of A

and btw when you call B.destroy() and B extends A both B.onDestroy() and A.onDestroy() get called (in that order)
 
so lets say there is triggernig unit who stopped the channeling, how would we load the data based on the unit, do we have to do a loop to so what unit that unit is, or can we use any other method? like TriggeringUnits = GetTriggerUnit() for each loop and if/then ... you know the rest.
 
oh you mean attachments well just use Vexorians Table for that
something like the following should work
JASS:
scope Bla initializer init
    globals
        private HandleTable UnitTable
    endglobals

    function Attach takes unit u, #struct# s returns nothing
        set UnitTable[u] = integer(s)
    endfunction

    function GetAttached takes unit u returns #struct#
        return #struct#(UnitTable[u])
    endfunction

    private function init takes nothing returns nothing
        set UnitTable = HandleTable.create()
    endfunction
endscope

o/c you would have to replace #struct# by your struct name
 
Status
Not open for further replies.
Back
Top