Save/Load Code, Yet Another

Set Save[3] = Hero[ Player number of Player 1 ]
Set Save[4] = Level of (Hero[ Player number of Player 1 ])
Set SaveCount = 4
...
:
I've come across problems with this,
Hero..? I checked all the integer options their is no Hero[Player number of Player 1] so then i tried to set it to Hero - Hero Attribute, but the Unit options aren't useful any other way i can do...?
Set Save[3] = Hero[ Player number of Player 1 ]
Set Save[4] = Level of (Hero[ Player number of Player 1 ])
Set SaveCount = 4
...
:

Oh and i can't have select unit <gen> because the unit is created.
 
> there is no Hero[Player number of Player 1]

You could make one if you wanted or needed to.
Create a variable called "Hero", of type "Unit", with a check in "array".
Put the Heroes in as the players get them.

Or, well, have a look at the couple examples the map comes with.
The first "Hero" sample uses "Pick every unit in ..." to get the player's Hero.
 
Help

I downloaded your test map and tryed to run it but it wouldn't run it would just open WC3 main screen. Is there a bug or is it just my comp?
 
There are no known problems with running the demo map.
After 300+ downloads people would have noticed.

You're assumed to have TFT, latest version, though.
 
Ok i Need Help!

when i saved the map after doing what u wrote
i got 3 compile errors on each SaveLoad Save and SaveLoad Load Triggers about An Expected Name Please Help ASAP Thanks
 
> i got 3 compile errors on each SaveLoad Save and SaveLoad Load Triggers about An Expected Name Please Help ASAP Thanks

Post your code....
 
Post your code....[/QUOTE]

Code:
SaveLoad
    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
    Conditions
    Actions
        Set Save[1] = 123
        Set Save[2] = 456
        Set Save[3] = 7890
        Set SaveCount = 3
        Custom script:   set udg_Code = SaveLoad_Encode()
        Quest - Display to (Player group((Triggering player))) the Secret message: Your Code:
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
        Set TempUnit = (Picked unit)
        Custom script:   set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
        Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
        Custom script:   set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Code:
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
    Conditions
        (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
        (Length of (Entered chat string)) Greater than 6
    Actions
        Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
        Custom script:   set udg_Validate = SaveLoad_Decode( udg_Code )
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Validate Equal to False
            Then - Actions
                Game - Display to (Player group((Triggering player))) the text: There's some error ...
                Skip remaining actions
            Else - Actions
                Set SaveCount = 1
                Custom script:   set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
                Unit - Create 1 TempUnitType for (Triggering player) at (Center of Start Team 1 <gen>) facing Default building facing degrees
                Set SaveCount = (SaveCount + 1)
                Hero - Set (Last created unit) Hero-level to Save[SaveCount], Hide level-up graphics
                For each (Integer A) from 1 to Save[SaveCount], do (Actions)
                    Loop - Actions
                        Set SaveCount = (SaveCount + 1)
                        Custom script:   set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
                        Hero - Create TempItemType and give it to (Last created unit)
                        Set SaveCount = (SaveCount + 1)
                        Item - Set charges remaining in (Last created item) to Save[SaveCount]


These are the errors

Code:
1. Custom script:   set udg_Code = SaveLoad_Encode()
2. Custom script:   set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
3. Custom script:   set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
4. Custom script:   set udg_Validate = SaveLoad_Decode( udg_Code )
5. Custom script:   set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
6. Custom script:   set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
 
Do you have those variables made already? (With the correct Variable Type, and Array Size)
 
i have another question, i want to save units in an area for a player, say they have 4 units in region 1 and when you save it saves those units so that the next time you load you get those four units back in region 1. how do i do this?
 
I wanna use this code but in my map i add atributes with a dialog and whenenver u use the load it doesnt work alll the atributes are 1. any1 know how to fix this?
 
> say they have 4 units in region 1

Set UnitGroup = Units in region matching:
- Unit is owned by Triggering player
- Unit is (not) a Hero
- Unit is alive
Set Save[...] = Number of units in UnitGroup
Pick every unit in UnitGroup and do
... add it to the Save array.

And the other way around to load them back.


> I add attributes with a dialog

Save them...

Set Save[...] = Strength of (Picked unit)
Set Save[...] = Agility ...
...

And restore them in the load part.
 
thnx and i gotta nother 3 Questions.

1st. For Storing Items Couldnt You Just Do This.

Item - Pick every item in (Playable map area) and do (Actions)
Loop - Actions
Set SaveLoad_Items[1] = (Item-type of (Picked item))



2nd. How Do you change the clolors of the numbers / letters i did this.

Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: ((|c00FF8000 + Code) + |r)

but only part of the code was the color i wanted it to be.


And 3rd
Most Of The Time when i load the atributes Are 4,5,6 instead of the ones saved?
Or THe Heroe Doesnt Load but it says it Worked.
 
Hey AceHeart. I've been using your code for and RPG map I've been working on, and everything has been going extremely smooth. However, I have encountered a problem now.

I'm pretty much pushing the code to its limits. I'm saving 6 heroes, their level (not experience), their item (each hero can only hold 1), and the player's gold.

Now, it works for the most part, however, when the heroes are max level (level 100), and they're all holding 1 item, the code will not appear. I assume this is because it is exceeding some limit in length. However, when I drop one unit's item, the code will appear.

When I type the code in, there is still ample space left in the player's chat message, however, the code will not appear if it exceeds (aproximately) 75 characters - even though the player is able to type in far more than 75 characters.

Is there anyway to fix this?
 
the map editor won't allow me to open the map you gave. :confused:

first it comes up a bunch of 'trigger function does not exist on database: ...' notifications then a:

'This application has encountered a critical error:

Not enough storage is available to process this command.

Program: c:\program files\warcraft iii\worldedit.exe
Object: .PAVCWETriggerFunction@@



Press OK to terminate the application.'

i've tried effane's save/load code map as well and it comes up with the same error.
 
> Item - Pick every item in (Playable map area)

That only finds items on the ground. Not in inventories.


> How Do you change the clolors of the numbers / letters

Somewhere more or less near the top in the custom script section is a function that color-codes the result.
Find and edit it... carefully.


> it comes up a bunch of 'trigger function does not exist on database: ...'

Get the latest patch.


> Is there anyway to fix this?

Sort of.
Save them in two blocks of 3...


> "stash"

If by "stash" you mean some kind of unit with an inventory... well, there's a loop that finds and saves your Hero.
Take it and change the "pick every in" to find both your Hero and your "stash" unit.

There is an example trigger in the map that saves several Heroes, should you need some inspiration.
 
I'm so bad at this save and load stuff, When I copy your triggers into my map all I get is this "Script not found" or error and all this and I have to press ok like a million times, what do I need to do. Thanks for replying when you do!
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
  • The Helper The Helper:
    It will only be on internal network

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top