• 🏆 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!

I go away for a year . . . (Huge saving errors)

Status
Not open for further replies.
Level 4
Joined
Aug 20, 2004
Messages
65
I used to love tinkering with other people's JASS scripts (public ones only) without ever learning the basics. I stopped map making over a year ago and completely forget everything now.

But it always bothered me I have almost 100 custom heroes in an AoS map that was never completed and today I opened it up for the first time in years. The last time I tested it, it was working fine, but now when I try to save it I get over 4800 errors saying things like "expected a unit" or "expected an endif"

Here's the custom script I have in the map

Code:
// ===========================Damage Enemies System
function FilterIsEnemy takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer)
endfunction

function DamageEnemiesArea takes unit whichUnit, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns nothing
    local group g = CreateGroup()
    local boolexpr b = Condition(function FilterIsEnemy)
    local unit t
    set bj_groupEnumOwningPlayer = GetOwningPlayer(whichUnit)
    call GroupEnumUnitsInRange(g, x, y, radius, b)
    call DestroyBoolExpr(b)    
    loop
        set t = FirstOfGroup(g)
        exitwhen t == null
        call GroupRemoveUnit(g,t)
        call UnitDamageTarget(whichUnit,t,amount,attack, ranged,attackType,damageType,weaponType)
    endloop    
    call DestroyGroup(g)
    set g = null
    set b = null
endfunction
// ===========================









// ===========================Local Handle Vars   By: Kattana
function H2I takes handle h returns integer
    return h
    return 0
endfunction

// ===========================
function LocalVars takes nothing returns gamecache
    if udg_Cache == null then
               call FlushGameCache(InitGameCache("somename"))
               set udg_Cache = InitGameCache("somename")
    endif
    return udg_Cache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLocation takes handle subject, string name returns location
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
// ===========================

constant function TreeRegrowTime takes nothing returns real
    return 10.00 //the amount of time you want before the tree respawns
endfunction
//To add more trees press CTRl+D while looking at the Object Editor
//then follow the same format and add your tree's RAWCODE inside single quotes (Example ' ' )
function IsDesTree takes destructable a returns boolean
    local integer d=GetDestructableTypeId(a)
    if d =='ATtr' then
      return true
    elseif d=='BTtw' then
      return true
    elseif d=='KTtw' then
      return true
    elseif d=='YTft' then
      return true
    elseif d=='JTct' then
      return true
    elseif d=='YTst' then
      return true
    elseif d=='YTct' then
      return true
    elseif d=='YTwt' then
      return true
    elseif d=='JTwt' then
      return true
    elseif d=='DTsh' then
      return true
    elseif d=='FTtw' then
      return true
    elseif d=='CTtr' then
      return true
    elseif d=='ITtw' then
      return true
    elseif d=='NTtw' then
      return true
    elseif d=='OTtw' then
      return true
    elseif d=='ZTtw' then
      return true
    elseif d=='WTst' then
      return true
    elseif d=='LTlt' then
      return true
    elseif d=='GTsh' then
      return true
    elseif d=='Xtlt' then
      return true
    elseif d=='WTtw' then
      return true
    elseif d=='Attc' then
      return true
    elseif d=='BTtc' then
      return true
    elseif d=='CTtc' then
      return true
    elseif d=='ITtc' then
      return true
    elseif d=='NTtc' then
      return true
    elseif d=='ZTtc' then
      return true
    else
    return false
endif
endfunction
function RegrowTrees takes nothing returns nothing
    local destructable tree=GetDyingDestructable()
    call TriggerSleepAction(TreeRegrowTime())
    call DestructableRestoreLife( tree, GetDestructableMaxLife(tree), true )
    set tree=null
endfunction
function Trig_Int_Tree_Revival takes nothing returns nothing
    local trigger t
    if IsDesTree(GetEnumDestructable())==true then
    set t=CreateTrigger()
    call TriggerRegisterDeathEvent( t, GetEnumDestructable() )
    call TriggerAddAction(t,function RegrowTrees)
endif
endfunction
function Int_Tree_Revive takes nothing returns nothing
    call EnumDestructablesInRectAll( GetPlayableMapRect(), function Trig_Int_Tree_Revival )
endfunction
Some questions:
1) What could have happened to cause a (basically) fully functioning map to go haywire like this? Was the editor patched in any way that would cause this?
2) What do these custom scripts do? The tree regrowth is self explanatory, but I can't remember why I put in the other two.
3) Can I fix it?
4) What other information do I need to provide in order to get a better answer?
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
well if you have the error Expected Name, then either you have wrong variable names, or you put the wrong unit names. Normally with the error it tells you what part of the script is wrong, you check the name and make sure it matches a predetermined variable or a unit that is on the map. (That means he has been placed on the map and can be traced back to with <gen>)
 
Reading this tutorial might help:
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/make-map-work-patch-1-24-a-165482/

For a quick fix, look into this library:
http://www.wc3c.net/showthread.php?t=106558

The first thing you will want to do now that you are back is to get Jass NewGen Pack and download the latest JassHelper. It will allow you to compile libraries like the one I linked to above.

Kattana's local handle vars used the return bug, which has since been fixed, so now it is unusable and won't compile.
 
Level 4
Joined
Aug 20, 2004
Messages
65
Thanks, I'm glad it wasn't something I did by accident.

What exactly does the handle vars system do? What sort of custom spells does it effect? I just do map making as something to share with friends, so I'll probably end up deleting the parts of the map that used it instead of bothering to learn JASS now.
 
It was used to pass data from one function to another. It was used only by JASSers and it was used usually for spells with timers. (which pretty much means spells that are not instant)

The instant spells should be unharmed, but the others won't work anymore. You can click each spell, and look for anything with SetHandle. If it has that, it most likely uses the handle vars and sadly, doesn't work anymore. :(
 
Status
Not open for further replies.
Top