• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[vJASS] Fucked up my double linked index help!

Not open for further replies.
Level 15
Nov 30, 2007
private struct UnitList 
        thistype next
        thistype prev
        unit u
        real x
        real y
        texttag txt
        static integer count = 0
        static trigger t = CreateTrigger()
        static method add takes unit u, string name returns nothing 
            local thistype new = thistype.allocate()
            local integer id = GetHandleId(u)
            call BJDebugMsg("added")
            call SaveInteger(hash, id, 0, new)
            call SaveBoolean(hash, id, 1, true)
            set new.u = u
            set new.prev = thistype(0)
            set new.next = thistype(0).next
            set new.next.prev = new
            set thistype(0).next = new
            set thistype.count = thistype.count + 1
            set new.txt = CreateTextTag()
            call SetTextTagText(new.txt, name, 10.)
            call SetTextTagVisibility(new.txt, true)
            if thistype.count == 1 then 
                call EnableTrigger(thistype.t)
        static method remove takes unit u returns nothing
            local integer id = GetHandleId(u)
            local thistype old = LoadInteger(hash, id, 0) 
            call FlushChildHashtable(hash, id) 
            set old.next.prev = old.prev
            set old.prev.next = old.next
            set thistype.count = thistype.count - 1
            call DestroyTextTag(old.txt)
            if thistype.count == 0 then 
                call DisableTrigger(thistype.t)
            call old.deallocate()
        static method periodic takes nothing returns nothing
            local UnitList index = UnitList(0).next
            local real uX
            local real uY
                exitwhen index.u == null
                set uX = GetUnitX(index.u)
                set uY = GetUnitY(index.u)
                if not (index.x == uX and index.y == uY) then 
                    set index.x = uX
                    set index.y = uY
                    call SetTextTagPosUnit(index.txt, index.u, 100)
                set index = index.next
        static method onInit takes nothing returns nothing 
            call TriggerRegisterTimerEvent(thistype.t, 0.1, true)
            call TriggerAddAction(thistype.t, function thistype.periodic)
            call DisableTrigger(thistype.t)

- I want to attach a name to a unit but no floating text appears.

Nobody? I think it might be the floating texts not working properly...
Last edited by a moderator:
Not open for further replies.