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

Save/Load Code

Status
Not open for further replies.
Level 3
Joined
Sep 17, 2004
Messages
24
Was working on implementing a save/load code (CodeGen 1.0.1) into a map. The custom scripts (posted below) seem to corrupt the map when the map is saved in the world editor (JassHelper finds errors and the map is not playable in game). I am not very knowledgeable with custom scripts or jass, but would like to find the problem in the triggering. Posted below are TriggerHappy's triggers for the save/load code exactly as found on the map (for reference). One would figure that the save/load system would work if just copied and pasted into a different map, but even without changing any of the GUI below and pasting it into my map, it still corrupts the map. Again, i am illiterate with JASS and custom script. any suggestions on how to get this to work? Feel free to state whatever further information you need.

  • CodeGen Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- -------------------- --------
      • Set SaveLoad_Alphabet = abcdefghkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoad_CheckName = True
      • Set SaveLoad_Security = True
      • Set SaveLoad_HyphenSpace = 4
      • Set SaveLoad_SeperationChar = -
      • Set SaveLoad_Lower = |c002a4580
      • Set SaveLoad_Number = |cffffcc00
      • Set SaveLoad_Upper = |cff008000
      • -------- -------------------- --------
      • -------- -------------------- --------
      • Set SaveLoad_MaxValue = 6
      • -------- -------------------- --------
      • -------- -------------------- --------
      • Set SaveLoad_Item[0] = (Item-type of No item)
      • Set SaveLoad_Item[1] = Claws of Attack +15
      • Set SaveLoad_Item[2] = Crown of Kings +5
      • Set SaveLoad_Item[3] = Kelen's Dagger of Escape
      • Set SaveLoad_Item[4] = Mask of Death
      • Set SaveLoad_Item[5] = Orb of Frost
      • Set SaveLoad_Item[6] = Ring of Protection +5
      • Set SaveLoad_ItemCount = 6
      • -------- -------------------- --------
      • -------- -------------------- --------
      • Set SaveLoad_Hero[0] = Blood Mage
      • Set SaveLoad_Hero[1] = Lich
      • Set SaveLoad_HeroCount = 1
      • -------- -------------------- --------
      • -------- -------------------- --------
      • Set SaveLoad_Full = SaveLoad_Alphabet
      • Set SaveLoad_Error = <Empty String>
      • Set SaveLoad_Base = (Length of SaveLoad_Alphabet)
      • Set SaveLoad_Char[0] = <Empty String>
      • Set Load[0] = 0
      • Set LoadCount = 0
      • Custom script: call CodeGen_Init()
  • CodeGen Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
      • Player - Player 2 (Blue) types a chat message containing -save as An exact match
      • Player - Player 3 (Teal) types a chat message containing -save as An exact match
      • Player - Player 4 (Purple) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • -------- Save heroes level. --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Hero level of Hero)
      • -------- Save players gold. --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Save heroes items. --------
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • Set SaveCount = (SaveCount + 1)
          • Set Item = (Item carried by Hero in slot (Integer A))
          • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
  • CodeGen Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: SaveLoad_Error
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Load heroes level --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set (Last created unit) Hero-level to Load[LoadCount], Hide level-up graphics
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now items --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
 
Level 10
Joined
Jan 20, 2011
Messages
492
Does triggerhappy have any jass coding in his save/load in the original map? Since that may contain key variables resulting in this error.

If he does have them, copy it into your map and see if it works (You don't have to understand the Jass if it's similar to another save/load code all you do is copy it). They can be found at the top of your trigger editor page, where it has the name of your map.w3x
 
Level 3
Joined
Sep 17, 2004
Messages
24
Thanks for pointing that out, i missed that code. Interestingly, if I make a new map with nothing in it and paste the code, it works. If I paste it into my map, it doesn't work. There must be something in my map interfering with the custom script. I have deleted all triggers and all variables in the map, but the problem still persists.
 
Status
Not open for further replies.
Top