• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Why won't this save?

Status
Not open for further replies.

ndh

ndh

Level 8
Joined
Apr 21, 2012
Messages
344
edo494 made this trigger for my project, but it won't save in my map. On his test map he can save it just fine, but I still can't. I thought it was an issue with Jasshelper, but to be honest i'm not quite sure now. If it helps any, i use JNGP.

JASS:
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
    
    One map, one hashtable. Welcome to NewTable 3.1
    
    This library was originally called NewTable so it didn't conflict with
    the API of Table by Vexorian. However, the damage is done and it's too
    late to change the library name now. To help with damage control, I
    have provided an extension library called TableBC, which bridges all
    the functionality of Vexorian's Table except for 2-D string arrays &
    the ".flush(integer)" method. I use ".flush()" to flush a child hash-
    table, because I wanted the API in NewTable to reflect the API of real
    hashtables (I thought this would be more intuitive).
    
    API
    
    ------------
    struct Table
    | static method create takes nothing returns Table
    |     create a new Table
    |    
    | method destroy takes nothing returns nothing
    |     destroy it
    |    
    | method flush takes nothing returns nothing
    |     flush all stored values inside of it
    |    
    | method remove takes integer key returns nothing
    |     remove the value at index "key"
    |    
    | method operator []= takes integer key, $TYPE$ value returns nothing
    |     assign "value" to index "key"
    |    
    | method operator [] takes integer key returns $TYPE$
    |     load the value at index "key"
    |    
    | method has takes integer key returns boolean
    |     whether or not the key was assigned
    |
    ----------------
    struct TableArray
    | static method operator [] takes integer array_size returns TableArray
    |     create a new array of Tables of size "array_size"
    |
    | method destroy takes nothing returns nothing
    |     destroy it
    |
    | method flush takes nothing returns nothing
    |     flush and destroy it
    |
    | method operator size takes nothing returns integer
    |     returns the size of the TableArray
    |
    | method operator [] takes integer key returns Table
    |     returns a Table accessible exclusively to index "key"
*/
    
globals
    private integer less = 0    //Index generation for TableArrays (below 0).
    private integer more = 8190 //Index generation for Tables.
    //Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
    
    private hashtable ht = InitHashtable()
    private key sizeK
    private key listK
endglobals
    
private struct dex extends array
    static method operator size takes nothing returns Table
        return sizeK
    endmethod
    static method operator list takes nothing returns Table
        return listK
    endmethod
endstruct
    
private struct handles extends array
    method has takes integer key returns boolean
        return HaveSavedHandle(ht, this, key)
    endmethod
    method remove takes integer key returns nothing
        call RemoveSavedHandle(ht, this, key)
    endmethod
endstruct
    
private struct agents extends array
    method operator []= takes integer key, agent value returns nothing
        call SaveAgentHandle(ht, this, key, value)
    endmethod
endstruct
    
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
    method operator [] takes integer key returns $TYPE$
        return Load$FUNC$(ht, this, key)
    endmethod
    method operator []= takes integer key, $TYPE$ value returns nothing
        call Save$FUNC$(ht, this, key, value)
    endmethod
    method has takes integer key returns boolean
        return HaveSaved$SUPER$(ht, this, key)
    endmethod
    method remove takes integer key returns nothing
        call RemoveSaved$SUPER$(ht, this, key)
    endmethod
endstruct
private module $TYPE$m
    method operator $TYPE$ takes nothing returns $TYPE$s
        return this
    endmethod
endmodule
//! endtextmacro
    
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
    method operator [] takes integer key returns $TYPE$
        return Load$FUNC$Handle(ht, this, key)
    endmethod
    method operator []= takes integer key, $TYPE$ value returns nothing
        call Save$FUNC$Handle(ht, this, key, value)
    endmethod
endstruct
private module $TYPE$m
    method operator $TYPE$ takes nothing returns $TYPE$s
        return this
    endmethod
endmodule
//! endtextmacro
    
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
    
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
    
struct Table extends array
    
    // Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
    implement realm
    implement booleanm
    implement stringm
    implement playerm
    implement widgetm
    implement destructablem
    implement itemm
    implement unitm
    implement abilitym
    implement timerm
    implement triggerm
    implement triggerconditionm
    implement triggeractionm
    implement eventm
    implement forcem
    implement groupm
    implement locationm
    implement rectm
    implement boolexprm
    implement soundm
    implement effectm
    implement unitpoolm
    implement itempoolm
    implement questm
    implement questitemm
    implement defeatconditionm
    implement timerdialogm
    implement leaderboardm
    implement multiboardm
    implement multiboarditemm
    implement trackablem
    implement dialogm
    implement buttonm
    implement texttagm
    implement lightningm
    implement imagem
    implement ubersplatm
    implement regionm
    implement fogstatem
    implement fogmodifierm
    implement hashtablem
    
    method operator handle takes nothing returns handles
        return this
    endmethod
    
    method operator agent takes nothing returns agents
        return this
    endmethod
    
    //set this = tb[GetSpellAbilityId()]
    method operator [] takes integer key returns Table
        return LoadInteger(ht, this, key)
    endmethod
    
    //set tb[389034] = 8192
    method operator []= takes integer key, Table tb returns nothing
        call SaveInteger(ht, this, key, tb)
    endmethod
    
    //set b = tb.has(2493223)
    method has takes integer key returns boolean
        return HaveSavedInteger(ht, this, key)
    endmethod
    
------------here is where the error came up-----------
    //call tb.remove(294080)
    method remove takes integer key returns nothing
        call RemoveSavedInteger(ht, this, key)
    endmethod
-----------------------------------------------------    
    //Remove all data from a Table instance
    method flush takes nothing returns nothing
        call FlushChildHashtable(ht, this)
    endmethod
    
    //local Table tb = Table.create()
    static method create takes nothing returns Table
        local Table this = dex.list[0]
        
        if this == 0 then
            set this = more + 1
            set more = this
        else
            set dex.list[0] = dex.list[this]
            call dex.list.remove(this) //Clear hashed memory
        endif
        
        debug set dex.list[this] = -1
        return this
    endmethod
    
    // Removes all data from a Table instance and recycles its index.
    //
    //     call tb.destroy()
    //
    method destroy takes nothing returns nothing
        debug if dex.list[this] != -1 then
            debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
            debug return
        debug endif
        
        call this.flush()
        
        set dex.list[this] = dex.list[0]
        set dex.list[0] = this
    endmethod
    
    //! runtextmacro optional TABLE_BC_METHODS()
endstruct
    
//! runtextmacro optional TABLE_BC_STRUCTS()
    
struct TableArray extends array
    
    //Returns a new TableArray to do your bidding. Simply use:
    //
    //    local TableArray ta = TableArray[array_size]
    //
    static method operator [] takes integer array_size returns TableArray
        local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
        local TableArray this = tb[0]         //The last-destroyed TableArray that had this array size
        
        debug if array_size <= 0 then
            debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
            debug return 0
        debug endif
        
        if this == 0 then
            set this = less - array_size
            set less = this
        else
            set tb[0] = tb[this]  //Set the last destroyed to the last-last destroyed
            call tb.remove(this)  //Clear hashed memory
        endif
        
        set dex.size[this] = array_size //This remembers the array size
        return this
    endmethod
    
    //Returns the size of the TableArray
    method operator size takes nothing returns integer
        return dex.size[this]
    endmethod
    
    //This magic method enables two-dimensional[array][syntax] for Tables,
    //similar to the two-dimensional utility provided by hashtables them-
    //selves.
    //
    //ta[integer a].unit[integer b] = unit u
    //ta[integer a][integer c] = integer d
    //
    //Inline-friendly when not running in debug mode
    //
    method operator [] takes integer key returns Table
        static if DEBUG_MODE then
            local integer i = this.size
            if i == 0 then
                call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
                return 0
            elseif key < 0 or key >= i then
                call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
                return 0
            endif
        endif
        return this + key
    endmethod
    
    //Destroys a TableArray without flushing it; I assume you call .flush()
    //if you want it flushed too. This is a public method so that you don't
    //have to loop through all TableArray indices to flush them if you don't
    //need to (ie. if you were flushing all child-keys as you used them).
    //
    method destroy takes nothing returns nothing
        local Table tb = dex.size[this.size]
        
        debug if this.size == 0 then
            debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
            debug return
        debug endif
        
        if tb == 0 then
            //Create a Table to index recycled instances with their array size
            set tb = Table.create()
            set dex.size[this.size] = tb
        endif
        
        call dex.size.remove(this) //Clear the array size from hash memory
        
        set tb[this] = tb[0]
        set tb[0] = this
    endmethod
    
    private static Table tempTable
    private static integer tempEnd
    
    //Avoids hitting the op limit
    private static method clean takes nothing returns nothing
        local Table tb = .tempTable
        local integer end = tb + 0x1000
        if end < .tempEnd then
            set .tempTable = end
            call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
        else
            set end = .tempEnd
        endif
        loop
            call tb.flush()
            set tb = tb + 1
            exitwhen tb == end
        endloop
    endmethod
    
    //Flushes the TableArray and also destroys it. Doesn't get any more
    //similar to the FlushParentHashtable native than this.
    //
    method flush takes nothing returns nothing
        debug if this.size == 0 then
            debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
            debug return
        debug endif
        set .tempTable = this
        set .tempEnd = this + this.size
        call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
        call this.destroy()
    endmethod
    
endstruct
    
endlibrary


JASS:
globals
    TableArray millshash
endglobals

function Trig_onInit_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit first
    call GroupEnumUnitsInRange(g, 0., 0., 10000., null)
    loop
        set first = FirstOfGroup(g)
        call GroupRemoveUnit(g, first)
        exitwhen first == null
        if GetUnitTypeId(first) == 'hlum' then
            set millshash[1][GetHandleId(first)] = 0
            call GroupAddUnit(lumbers, first)
        endif
        set first = null
    endloop
    call DestroyGroup(g)
    set g = null
endfunction

//===========================================================================
function InitTrig_onInit takes nothing returns nothing
    set gg_trg_onInit = CreateTrigger(  )
    call TriggerAddAction( gg_trg_onInit, function Trig_onInit_Actions )
endfunction

JASS:
globals
    //TableArray millshash
endglobals

function Trig_lumbermillspawning_Actions takes nothing returns nothing
    local unit first = null
    local unit spawned = null
    local group tempgroup = CreateGroup()
    local destructable d = null
    local rect re = null
    local real x = 0
    local integer looper = 0
    local real y = 0
    local integer i
    local unit firsttree = null
    local group neartree = CreateGroup()
    loop
        set first = FirstOfGroup(lumbers)
        exitwhen first == null
        call GroupRemoveUnit(lumbers, first)
        call GroupAddUnit(tempgroup, first)
        if GetUnitTypeId(first) == 'hlum' and not IsUnitType(first, UNIT_TYPE_DEAD) then
            set i = millshash[1][GetHandleId(first)]
            if i < 5 then
                set looper = 0
                set i = i+1
                set millshash[1][GetHandleId(first)]=i
                set x = GetUnitX(first)
                set y = GetUnitY(first)
                set re = Rect(x-650, y-650, x+650, y+650)
                set d = RandomDestructableInRectSimpleBJ(re)
                if not (d == null) then
                    call GroupEnumUnitsInRange(neartree, GetWidgetX(d), GetWidgetY(d), 450., null)
                    set firsttree = FirstOfGroup(neartree)
                    if not( firsttree == null )then
                        call RemoveRect(re)
                        set d = null
                        set re = Rect(x-850, y-850, x+850, y+850)
                        set d = RandomDestructableInRectSimpleBJ(re)
                    endif
                else
                    call RemoveRect(re)
                    set re = Rect(x-850, y-850, x+850, y+850)
                    set d = null
                    set d = RandomDestructableInRectSimpleBJ(re)
                endif
                set firsttree = null
                set spawned = CreateUnit(GetOwningPlayer(first), 'h00W', GetUnitX(first)+50, GetUnitY(first)+50, 0)
                set millshash[2].unit[GetHandleId(spawned)] = first
                set millshash[i+5].unit[GetHandleId(first)] = spawned
                call IssueTargetOrder(spawned, "harvest", d)
            endif
        endif
        set first = null
        set spawned = null
        call RemoveRect(re)
        set re = null
        set d = null
    endloop
    loop
        set first = FirstOfGroup(tempgroup)
        exitwhen first == null
        call GroupRemoveUnit(tempgroup, first)
        call GroupAddUnit(lumbers, first)
        set first = null
    endloop
    call DestroyGroup(tempgroup)
    call DestroyGroup(neartree)
    set neartree = null
    set tempgroup = null
endfunction

//===========================================================================
function InitTrig_lumbermillspawning takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    set millshash = TableArray[50]
    call TriggerRegisterTimerEventPeriodic( t, 10.00 )
    call TriggerAddAction( t, function Trig_lumbermillspawning_Actions )
    set t = null
endfunction

JASS:
function Trig_milldies_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'hlum'
endfunction

function Trig_milldies_Actions takes nothing returns nothing
    local integer looper = 1
    call GroupRemoveUnit(lumbers, GetTriggerUnit())
    loop
        exitwhen looper == 10
        call KillUnit(millshash[looper+5].unit[GetHandleId(GetTriggerUnit())])
        set millshash[looper+5].unit[GetHandleId(GetTriggerUnit())] = null
        set looper = looper+1
    endloop
endfunction

//===========================================================================
function InitTrig_milldies takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function Trig_milldies_Conditions ) )
    call TriggerAddAction( t, function Trig_milldies_Actions )
    set t = null
endfunction

JASS:
globals
    group lumbers = CreateGroup()
endglobals

function Trig_constructingmill_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetConstructedStructure()) == 'hlum'
endfunction

function Trig_constructingmill_Actions takes nothing returns nothing
    call GroupAddUnit(lumbers, GetConstructedStructure())
endfunction

//===========================================================================
function InitTrig_constructingmill takes nothing returns nothing
    set gg_trg_constructingmill = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_constructingmill, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
    call TriggerAddCondition( gg_trg_constructingmill, Condition( function Trig_constructingmill_Conditions ) )
    call TriggerAddAction( gg_trg_constructingmill, function Trig_constructingmill_Actions )
endfunction

JASS:
function Trig_paesantdies_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'hpea'
endfunction

function Trig_paesantdies_Actions takes nothing returns nothing
    local unit u = millshash[2].unit[GetHandleId(GetTriggerUnit())]
    set millshash[1][GetHandleId(u)] = millshash[1][GetHandleId(u)] - 1
    set u = null
endfunction

//===========================================================================
function InitTrig_paesantdies takes nothing returns nothing
    set gg_trg_paesantdies = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_paesantdies, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_paesantdies, Condition( function Trig_paesantdies_Conditions ) )
    call TriggerAddAction( gg_trg_paesantdies, function Trig_paesantdies_Actions )
endfunction
 
Last edited:
Level 13
Joined
Sep 13, 2010
Messages
550
Is vJass syntax enabled? If not, go to JassHelper( on the main window toolbar ) and untick "Disable vJass syntax". If it still does not work, check if your JassHelper is the newest edition. If not, use the link upper given by PnF. It does not need wc3c.net account so no worries. If it still crashes, then there is something misconfigurated, maybe try disabling "Reinventing the Craft".
 
Level 9
Joined
Jul 10, 2011
Messages
562
ndh if it doesnt show up the errors you have to go JassHelper>Show previous errors and there itll show up....had the problem myself...you have to update the jasshelper.^^
 

ndh

ndh

Level 8
Joined
Apr 21, 2012
Messages
344
Hmm i checked it, says... Unable to find textmacro: "optional"

When i click on it i get brought to this...

//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod

It is under the Table by Bribe.

I marked the part in the Jass code so it can easily be found
 

ndh

ndh

Level 8
Joined
Apr 21, 2012
Messages
344
Now i cant even open the map -_-

"Trigger function does not exist in database: IssueImmediateOrderById"

And then it crashes...

Critical Error message
Object: .PAVCWETriggerFunction@@
 
Last edited:
Level 13
Joined
Sep 13, 2010
Messages
550
Ehh, not everything is added into GUI. Not even every BJ! UMSWE-WEU has few more added as an extension. Where can you see playing sound only for one player? There is a BJ for it. "IssueImmediateOrderById" is not only the native call, its the name of the entry what is not found( Actually entry name is the call name ).
 
  • Like
Reactions: ndh
Status
Not open for further replies.
Top