1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  5. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  6. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  7. The results are out! Check them out.
    Dismiss Notice
  8. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  9. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

CodeGen 1.0.2

Submitted by TriggerHappy
This bundle is marked as approved. It works and satisfies the submission rules.
Introduction

Sometimes you need to transfer data between games in order to keep the progress you've made. For example in RPG maps you probably want to save your hero, levels, gold and items so you can continue next time you play. The way this is done in Warcraft III by generating codes that contain all of your data, which can later be re-entered to restore that saved information. This is nothing new in the modding world however it's commonly asked about and requested yet many people still have issues. This is part of the reason why I decided to create an easy to use, universal, GUI-friendly save and load system which I'm calling the Code Generator.

Main Features
  1. Player-name sensitive (optional).
  2. Highly configurable.
  3. Can be used in the normal World Editor (doesn't require JNGP).
  4. Very easy to use.

Configuration

  • -------- -------------------- --------
  • -------- The below options are for saving load codes to the Warcraft III folder. --------
  • -------- You can modify the file name via the SaveLoad_Filename variable within the save trigger. --------
    • -------- -------------------- --------
    • Set SaveLoad_SaveToDisk = True
    • Set SaveLoad_Directory = Save
    • -------- -------------------- --------
    • -------- Some configurables --------
    • -------- -------------------- --------
    • 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
    • -------- -------------------- --------
    • -------- Increase the value if you want to save bigger numbers --------
    • -------- Decrease it if you want to generate a smaller save code but only be able to save smaller values --------
    • -------- It's suggested to not increase it above 7 --------
    • -------- -------------------- --------
    • Set SaveLoad_MaxValue = 6
    • -------- -------------------- --------
    • -------- Store all the heroes you want to be able to be saved below. --------
    • -------- -------------------- --------
    • Set SaveLoad_Hero[0] = Blood Mage
    • Set SaveLoad_Hero[1] = Lich
    • Set SaveLoad_Hero[2] = Blademaster
    • Set SaveLoad_Hero[3] = Demon Hunter
    • Set SaveLoad_HeroCount = 3
    • -------- -------------------- --------
    • -------- Store all the abilities you want to be able to be saved below. --------
    • -------- -------------------- --------
    • Set SaveLoad_Abilities[0] = Flame Strike
    • Set SaveLoad_Abilities[1] = Siphon Mana
    • Set SaveLoad_Abilities[2] = Phoenix
    • Set SaveLoad_Abilities[3] = Banish
    • Set SaveLoad_AbilityCount = 3
    • -------- -------------------- --------
    • -------- Store all the items you want to be able to be saved below. --------
    • -------- -------------------- --------
    • 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
    • -------- -------------------- --------
    • -------- Don't modify below this line. --------
    • -------- This is just here to copy variables to your map --------
    • -------- -------------------- --------
    • 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()

Installation
  1. Make sure your settings allow copying variables (Image)
  2. Copy the CodeGen folder over to your map.
  3. Paste the maps script into yours (Image)

How do I use it?

Let's take a look at the most basic example.

  • Set Save[0] = (Player 1 (Red) Current gold)
  • Custom script: set udg_Code = CodeGen_Compile()
  • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code

The above will save Players 1's gold. Simple, isn't it? Now you're probably asking "How do I load it?".

  • -------- 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
  • Player - Set Player 1 (Red) Current gold to Load[0]

Equally as simple and there are more examples are available in the demo map.

Keywords:
save,load,save load,save and load,code,codegen,code gen,triggerhappy,password,gen,generator,generate,preloadgen,preload,file,io,to,disk
Contents

CodeGen v1.0.2 (Map)

Reviews
Moderator
8 March 2014 PurgeandFire: Approved. Review: http://www.hiveworkshop.com/forums/2496968-post145.html 21 December 2013 Bribe: changed status to needs fix. 8 Sep 2011 Bribe: Deprecated in favor of: Save/Load with Snippets 21:27, 29th Aug...
  1. Tiche3

    Tiche3

    Joined:
    Jun 25, 2009
    Messages:
    432
    Resources:
    1
    Spells:
    1
    Resources:
    1
    In your face Anachron! (no offence)
    And yes, i will choose this over the other systems that are not even in this website. (Cause this one is very GUI friendly :p)

    EPIC :D
     
  2. light bolt30

    light bolt30

    Joined:
    Jan 31, 2009
    Messages:
    1,847
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Nice simple save/load system, might prove useful for some users.
     
  3. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    its a nice simple system, though I wont probably use it since I've grown accustomed to another one... and its really useful for those who wants simple code gens...

    its inferior to Hanky's in a advanced perspective but there isn't a rule which says that systems inferior to others should be rejected...
     
  4. Marsal

    Marsal

    Joined:
    Jun 24, 2009
    Messages:
    1,345
    Resources:
    15
    Maps:
    1
    Spells:
    14
    Resources:
    15
    triggerhappy i use this system in my orpg (click on sig) i use the prev version and i have to ask: how can i add to the code that the backpack items and hero abilities are saved? i use the backpack as a hero
     
  5. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,671
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    @Anachron

    The system is obviously useful for a certain type of users, and it's a fairly different system from Hanky's. Each have their own strong points and users will pick which they feel works best for them. Stop complaining and trying to start an argument. Oh, and there's a difference between being repetitive and offering variety, so this system complies with all of the site rules.

    I won't be replying to anymore of your posts here Anachron, quit spamming my thread.
     
  6. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Wow, I remember CodeGen 0.05! :grin:

    It worked fine on my ORPG until recently, was it deactivated or something? (How that would affect me, if even possible, makes no sense at all).

    Nevertheless, this system is useful and I'm glad it's approved. :smile:

    Keep up the good work TriggerHappy, however I do have one question. When you say, it saves the player's name, you mean that when I save my hero with the name Vital_Sin, and I try to load the hero with the name Arkon_Kaos, it won't work. Right?

    I tested the map, and tried to figure that out, but I couldn't tell if I was typing the code wrong or if it saved to the player name, as the code would dissapear faster than I can type it three times. :thumbs_up:

    Excellent system, and Thanks,
    -Arkon Kaos (A.K.A. Vital_Sin)
     
  7. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    nice to see that you worked on this!

    I guess that you remade it totally as you told in 0.05? Very good none the less.
     
  8. Forgotten_Warlord

    Forgotten_Warlord

    Joined:
    Nov 6, 2009
    Messages:
    1,379
    Resources:
    38
    Models:
    34
    Icons:
    4
    Resources:
    38
    well to make it ORIGINAL... add in to your code abilities. This can be done the same way as you do items.

    A good save/load system contains:
    EXP (x)
    Items (x)
    Gold (x)
    Lumber (x)
    Abilities (n/a)
    Extra Optional Integers (n/a)

    Although your system could easily have added the optional integers some people don't quite have the experience in triggers to do so themselves.

    But other than that I like how short the code is so you deserve a 4/5 because of how tedious making one of these systems can be, but until there are abilities it wont be a 5/5
     
  9. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    I thought you could add abilities.

    Just make all abilities pre-loaded into variables, pref. a ability variable with array.

    Store the array number for every ability the unit has.

    Then when you load it, you just add the ability and the array number you saved.
     
  10. Vengeancekael

    Vengeancekael

    Joined:
    Aug 11, 2009
    Messages:
    5,746
    Resources:
    16
    Tools:
    1
    Maps:
    13
    Spells:
    1
    StarCraft II Resources:
    1
    Resources:
    16
    Excellent System, useful for GUI users.
    The GUI triggers are simple and can easily be customized.

    No doubt 5/5 from me.
     
  11. Shaki

    Shaki

    Joined:
    Jan 20, 2009
    Messages:
    19
    Resources:
    0
    Resources:
    0
    Hey first off i want to say thank you alot for this. It works 100%. I just have a request if you do not mind. Is there any way to make the save/load CODE the player uses have a SET length. IE: Make the code LENGTH always 16? Thanks. I give your trigger system a 4/5 for it could use some more features and its not 100% pefect but its usable i use it and i like it personally. Thanks.
     
  12. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    You can only hold so much data in every character... For really big games that save EVERYTHING... 16 might not be enough... You might want to take that into consideration and look at what all you're saving.

    Also, try posting this in the Requests section. :grin:
     
    Last edited: Oct 7, 2010
  13. cpjok

    cpjok

    Joined:
    Feb 18, 2010
    Messages:
    152
    Resources:
    0
    Resources:
    0
    seems awesome and looks easy to edit for my map but when i copy and paste CodeGen into my map and try the map it wont let me play the map

    dont show up and slots

    and when i click start it goes back to create a game

    any help ideas?
     
  14. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    you have to save the map before testing it or you should update your wc3 to the latest patch
     
  15. xorkatoss

    xorkatoss

    Joined:
    Jul 12, 2010
    Messages:
    1,527
    Resources:
    7
    Models:
    5
    Maps:
    1
    Spells:
    1
    Resources:
    7
    dude i got a problem
    call me a noob, call me an idiot but i don't care just help me
    i copy and paste the triggers in my map and when i try to save i get an error
    what do i have to do to import the triggers successfully?
    i would appreciate any help asap ty ;p
     
  16. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Did you copy the map's script into your map as well?
     
  17. Animoi666

    Animoi666

    Joined:
    Apr 8, 2009
    Messages:
    428
    Resources:
    0
    Resources:
    0
    This System works fine and all, very GUI-user friendly (unlike iGen -sigh-)
    But there are stil a few things i can't get working.... like saving the amount of charges an item has. a lot of Save/Load systems neglect putting it in the standard triggers =\

    At the moment i'm stil trying to fix that but i can't seem to find out what the problem is. if anyone can help me?
     
  18. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    its not that they forget, its just that they don't really need to... since the things that needs to be saved/loaded should be configured by the user of this system... those save-load triggers are just for examples on how to use the code generator...
     
  19. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    save the charge integer value into the code and when you load, you set the charges of the item to the integer
     
  20. Animoi666

    Animoi666

    Joined:
    Apr 8, 2009
    Messages:
    428
    Resources:
    0
    Resources:
    0
    Save
    • SaveLoad 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
        • Player - Player 5 (Yellow) types a chat message containing -save as An exact match
        • Player - Player 6 (Orange) types a chat message containing -save as An exact match
        • Player - Player 7 (Green) types a chat message containing -save as An exact match
        • Player - Player 8 (Pink) types a chat message containing -save as An exact match
      • Conditions
      • Actions
        • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
        • Set SaveCount = 0
        • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) and do (Set Hero = (Picked unit))
        • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
        • Set SaveCount = (SaveCount + 1)
        • -------- Save players gold. --------
        • Set Save[SaveCount] = ((Triggering player) Current gold)
        • Set SaveCount = (SaveCount + 1)
        • -------- Save players lumber. --------
        • Set Save[SaveCount] = ((Triggering player) Current lumber)
        • Set SaveCount = (SaveCount + 1)
        • -------- Save heroes EXP. --------
        • Set Save[SaveCount] = (Hero experience of Hero)
        • Set SaveCount = (SaveCount + 1)
        • -------- Save heroes items. --------
        • Set Save[SaveCount] = (Number of items carried by Hero)
        • For each (Integer Integer_A_Replacement) from 1 to 6, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Item-type of (Item carried by Hero in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
              • Then - Actions
                • Set SaveCount = (SaveCount + 1)
                • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                • Set SaveCount = (SaveCount + 1)
                • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
              • Else - Actions
        • -------- Show Code --------
        • Custom script: set udg_Code = CodeGen_Compile()
        • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code


    Load
    • SaveLoad 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
        • Player - Player 5 (Yellow) types a chat message containing -load as A substring
        • Player - Player 6 (Orange) types a chat message containing -load as A substring
        • Player - Player 7 (Green) types a chat message containing -load as A substring
        • Player - Player 8 (Pink) 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: Invalid code.
            • 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)) 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)
        • -------- Now load players gold --------
        • Set LoadCount = (LoadCount + 1)
        • Player - Set (Triggering player) Current gold to Load[LoadCount]
        • -------- Now load players Lumber --------
        • Set LoadCount = (LoadCount + 1)
        • Player - Set (Triggering player) Current lumber to Load[LoadCount]
        • -------- Load heroes EXP --------
        • Set LoadCount = (LoadCount + 1)
        • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
        • -------- Now items --------
        • Set LoadCount = (LoadCount + 1)
        • For each (Integer Integer_A_Replacement) from 0 to Load[LoadCount], do (Actions)
          • Loop - Actions
            • Set LoadCount = (LoadCount + 1)
            • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
            • Set LoadCount = (LoadCount + 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Load[LoadCount] Greater than 0
              • Then - Actions
                • Item - Set charges remaining in (Last created item) to Load[LoadCount]
              • Else - Actions


    -When you have 6 different potions with different amounts of charges, it saves/loads perfectly.
    -when you have 5 different potions with different amounts of charges and + 1 non-chargable item (its in the 6th slot). only the 5 potions will be saved/loaded
    -when you move the non-chargable item to lets say.. the 3rd slot, everything after the 3rd slot wont get saved/loaded.


    so yes, i did what you said a long time ago lolz, its just not working.