Save/Load Code, Yet Another

Discussion in 'Tutorial Repository' started by AceHart, Jan 21, 2007.

  1. TDestroyer

    TDestroyer New Member

    Ratings:
    +0 / 0 / -0
    OK i figured it out, i was picking up items in a (integer A loop), and i had another (integer A loop) running when items where picked up. So they interfered with each other. All i had to do was make some of the loops B loops and now it works.
     
  2. LoveTD's

    LoveTD's New Member

    Ratings:
    +34 / 0 / -0
    I wanted to add collours to the lower case alphabetic characters and this is what I've came up with:

    JASS:
    
    function SaveLoad_Color takes string s returns string
        local integer i = StringLength(s)
        local string c
        local string r = ""
    
        loop
            set i = i - 1
            set c = SubString(s,i,i + 1)
            if c == "0" or c == "1" or c == "2" or c == "3" or c == "4" or c == "5" or c == "6" or c == "7" or c == "8" or c == "9" then
                set r = "|cffffcc00" + c + "|r" + r
            elseif c == "-" then
                set r = "|cffdddddd-|r" + r
            elseif c == "a" or c == "b" or c == "c" or c == "d" or c == "e" or c == "f" or c == "g" or c == "h" or c == "i" or c == "j" or c == "k" or c == "l" or c == "m" or c == "n" or c == "o" or c == "p" or c == "q" or c == "r" c == "s" or c == "t" or c == "u" or c == "v" or c == "w" or c == "x" or c == "y" or c == "z" then
                set r = "|c0000ff80" + c + "|r" + r
            else
                set r = c + r
            endif
            exitwhen i <= 0
        endloop
        return r
    endfunction


    the problem is: I get 3 compile errors:

    Expected expression @:
    JASS:
            elseif c == "a" or c == "b" or c == "c" or c == "d" or c == "e" or c == "f" or c == "g" or c == "h" or c == "i" or c == "j" or c == "k" or c == "l" or c == "m" or c == "n" or c == "o" or c == "p" or c == "q" or c == "r" c == "s" or c == "t" or c == "u" or c == "v" or c == "w" or c == "x" or c == "y" or c == "z" then


    Expected 'endif" @:
    JASS:
    else


    Expected 'endif" @:
    JASS:
    endif


    can someone help me out on this?
     
  3. No_exit

    No_exit Regular User (What is Custom User Title?)

    Ratings:
    +40 / 0 / -0
    @ LoveTD's: You forgot an or between
    c == "r" c == "s"
    Fixed:
    JASS:
    elseif c == "a" or c == "b" or c == "c" or c == "d" or c == "e" or c == "f" or c == "g" or c == "h" or c == "i" or c == "j" or c == "k" or c == "l" or c == "m" or c == "n" or c == "o" or c == "p" or c == "q" or c == "r" or c == "s" or c == "t" or c == "u" or c == "v" or c == "w" or c == "x" or c == "y" or c == "z" then


    That will probably fix all error messages.
     
  4. Leazy

    Leazy You can change this now in User CP.

    Ratings:
    +50 / 0 / -0
    This is the first time I take time to look into a save/load code, god damn smart way how you did it man, and it's mad easy to implement! GJ & +rep

    Edit: I might have been a little too enthusiastic (not saying it's great though) but how do I add so it also saves ability levels? I understood everything but this line:

    Code:
    Custom script:   set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
    What should I replace that with if I'm storing ability levels?

    Thanks in advance
     
  5. Chocobo

    Chocobo White-Flower

    Ratings:
    +410 / 0 / -0
    set Save[SaveCount] = (Level of <ability> for <unit>)....
     
  6. Leazy

    Leazy You can change this now in User CP.

    Ratings:
    +50 / 0 / -0
    Owe, that's what I tried first, I dunno why I changed it though... it's easier than I thought. Thanks!
     
  7. LoveTD's

    LoveTD's New Member

    Ratings:
    +34 / 0 / -0
    I have another question on this system:

    is it possible to make a code whenever the game ends instead of typing
    -save? There won't be a lot of leavers this way ;)

    I tryed this:

    Trigger:
    • My game is ending
      • Events
        • My game ends :)
      • Conditions
      • Actions
        • Set Save[1] = Total_Score_of_player[1]
        • Set Save[2] = double_kills_player[1]
        • Set Save[3] = triple_kills_player[1]
        • Set Save[4] = overkills_player[1]
        • Set Save[5] = killtaculars_player[1]
        • Set Save[6] = killtrocitys_player[1]
        • Set Save[7] = killinmanjaros_player[1]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 1 (Red) for 60.00 seconds the text: Code
        • Set Save[1] = Total_Score_of_player[2]
        • Set Save[2] = double_kills_player[2]
        • Set Save[3] = triple_kills_player[2]
        • Set Save[4] = overkills_player[2]
        • Set Save[5] = killtaculars_player[2]
        • Set Save[6] = killtrocitys_player[2]
        • Set Save[7] = killinmanjaros_player[2]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 2 (Blue) for 60.00 seconds the text: Code
        • Set Save[1] = Total_Score_of_player[3]
        • Set Save[1] = Total_Score_of_player[3]
        • Set Save[2] = double_kills_player[3]
        • Set Save[3] = triple_kills_player[3]
        • Set Save[4] = overkills_player[3]
        • Set Save[5] = killtaculars_player[3]
        • Set Save[6] = killtrocitys_player[3]
        • Set Save[7] = killinmanjaros_player[3]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 3 (Teal) for 60.00 seconds the text: Code
        • Set Save[2] = double_kills_player[4]
        • Set Save[3] = triple_kills_player[4]
        • Set Save[4] = overkills_player[4]
        • Set Save[5] = killtaculars_player[4]
        • Set Save[6] = killtrocitys_player[4]
        • Set Save[7] = killinmanjaros_player[4]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 4 (Purple) for 60.00 seconds the text: Code
        • Set Save[2] = double_kills_player[5]
        • Set Save[3] = triple_kills_player[5]
        • Set Save[4] = overkills_player[5]
        • Set Save[5] = killtaculars_player[5]
        • Set Save[6] = killtrocitys_player[5]
        • Set Save[7] = killinmanjaros_player[5]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 5 (Yellow) for 60.00 seconds the text: Code
        • Set Save[1] = Total_Score_of_player[6]
        • Set Save[2] = double_kills_player[6]
        • Set Save[3] = triple_kills_player[6]
        • Set Save[4] = overkills_player[6]
        • Set Save[5] = killtaculars_player[6]
        • Set Save[6] = killtrocitys_player[6]
        • Set Save[7] = killinmanjaros_player[6]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 6 (Orange) for 60.00 seconds the text: Code
        • Set Save[1] = Total_Score_of_player[7]
        • Set Save[2] = double_kills_player[7]
        • Set Save[3] = triple_kills_player[7]
        • Set Save[4] = overkills_player[7]
        • Set Save[5] = killtaculars_player[7]
        • Set Save[6] = killtrocitys_player[7]
        • Set Save[7] = killinmanjaros_player[7]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 7 (Green) for 60.00 seconds the text: Code
        • Set Save[1] = Total_Score_of_player[8]
        • Set Save[1] = Total_Score_of_player[8]
        • Set Save[2] = double_kills_player[8]
        • Set Save[3] = triple_kills_player[8]
        • Set Save[4] = overkills_player[8]
        • Set Save[5] = killtaculars_player[8]
        • Set Save[6] = killtrocitys_player[8]
        • Set Save[7] = killinmanjaros_player[8]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 8 (Pink) for 60.00 seconds the text: Code
        • Set Save[2] = double_kills_player[9]
        • Set Save[3] = triple_kills_player[9]
        • Set Save[4] = overkills_player[9]
        • Set Save[5] = killtaculars_player[9]
        • Set Save[6] = killtrocitys_player[9]
        • Set Save[7] = killinmanjaros_player[9]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 9 (Gray) for 60.00 seconds the text: Code
        • Set Save[2] = double_kills_player[10]
        • Set Save[3] = triple_kills_player[10]
        • Set Save[4] = overkills_player[10]
        • Set Save[5] = killtaculars_player[10]
        • Set Save[6] = killtrocitys_player[10]
        • Set Save[7] = killinmanjaros_player[10]
        • Set SaveCount = 7
        • Custom script: set udg_Code = SaveLoad_Encode()
        • Game - Display to Player Group - Player 10 (Light Blue) for 60.00 seconds the text: Code


    but this didnt work... When I tryed loading this code it said that its an invalid code :(
    (didn't loop it since I wanted to see if it works first.. And it didnt :()
     
  8. Bitterstone

    Bitterstone New Member

    Ratings:
    +1 / 0 / -0
    Gold & Lumber

    I tried this out and i'm afraid this is way too advanced for me even though i've been programming and used the Warcraft Editor for many many years, though i've never ever created a single Custom Script so I don't get any of that. :banghead:

    Well, my problem is, I can't seem to get Gold and Lumber to be saved and loaded properly in the "Save Load Hero with items" section. It's probably really easy once you get the hang of it but I just can't get it right.
     
  9. TriggerHappy

    TriggerHappy ...

    Ratings:
    +341 / 0 / -0
    Everyone should know that the creator has left TheHelper long ago.
     
  10. xXGauntletXx

    xXGauntletXx New Member

    Ratings:
    +4 / 0 / -0
    Even if he did, I'm sure there are others here that can help with it, like Romek or andrewgosu.

    Anyway this code is working perfectly for me.
     
  11. Necrolytie

    Necrolytie Member

    Ratings:
    +0 / 0 / -0
    Have one Demo-Map??? :confused:
     
  12. tooltiperror

    tooltiperror Super Moderator Staff Member

    Ratings:
    +233 / 0 / -0
    Demo-map right here.
     
  13. Lmfaocj

    Lmfaocj Active Member

    Ratings:
    +1 / 0 / -0
    Lol, Thank you for the code.... This is the first code that ever worked for me... And it's so easy to learn how to edit it to how you want it.
    but the only thing that i am having trouble with is the abilities.
     
  14. Vunjo

    Vunjo New Member

    Ratings:
    +1 / 0 / -0
    Does it work for 1.24 version of WC3?
     
  15. Lmfaocj

    Lmfaocj Active Member

    Ratings:
    +1 / 0 / -0
    Trigger:
    • Set AATempInteger = SaveCount
      • Set SaveCount = 1


    Trigger:
    • Do Multiple ActionsFor each (Integer SaveCount) from (SaveCount + 1) to AATempInteger, do (Actions)
      • Loop - Actions
        • Do Multiple ActionsFor each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
          • Loop - Actions
            • Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
        • Set SaveCount = (SaveCount + 1)

    How does that work?
     
  16. Lmfaocj

    Lmfaocj Active Member

    Ratings:
    +1 / 0 / -0
    The point is to set nothing? or zero
     
  17. tonton302

    tonton302 Member

    Ratings:
    +0 / 0 / -0
    When i tried to use this save system in my map i saved thn tried to load and it wuld only load the item in slot 1. tried to fix bout 3 times and it never worked...

    does any1 no wats wrong?

    thanks
     
  18. Animoi666

    Animoi666 New Member

    Ratings:
    +0 / 0 / -0
    -bump-


    i got the Exact same problem, haven't managed to solve it yet.
    Ace, could you help?
     
  19. Sui-cookie

    Sui-cookie You can change this now in User CP.

    Ratings:
    +50 / 0 / -0
    guys, seriously =.= stop posting help things here.
    POST IN THE DAMN HELP SECTION!

    When it's posted there We'll probably help. sorry for being so blunt.. but if you read the responses i wouldn't have had to post this :/

    ~And btw, ace is gone. has been :/ for a looong time. Though i think he still hangs out and watches from some random account as to whats going on >.>
     
  20. Prince.Zero

    Prince.Zero New Member

    Ratings:
    +1 / 0 / -0
    wth? gui?

    :SAD:
     

Share This Page