Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,219
Easy Save and Load in GUI-Only works in Single Player until updated!-IntroductionGreetings. I decided to create a tutorial for saving/loading in GUI. I know that there are existing GUI systems out there. Code Gen and Ace Harts are the most famous ones. However this tutorial is directed for those that want to create their own, or the existing systems lack something that they need in terms of saving, whatever that might be. I also quickly want to mention that I wont explain any GUI actions in this tutorial since it's not for starters, unless you don't understand simple GUI actions yet, you should go and learn some GUI before heading back to this tutorial.Difficulty5/10What is needed?*above basic knowledge of GUI in general*New Gen Editor (JNGP) - Download *FILE I/O - Download *Local Files enabled (Extensions > Enable Local Files) What is file I/O and why do we use it?File I/O allows the user to create and read files which contain information of our choice.Pros: *Encrypts/Decrypts the information we decide to store into our files *Saves us a good chunck of work and effort *We don't need to care about a save code, which means using this method the user can type "-load" instead of "-load xxx xxxx xxx xx xxxxx" Cons: *file I/O is made in vJASS, which forces us to use custom scripts more than we should. PreperationsIn order to understand this tutorial fully you will need to know about GetLocalPlayer().Once you've done that. We will create our variable for the GetLocalPlayer().
*Player Name *Main Hero *Hero Level *Player Gold *Player Lumber For learning purposes I strongly suggest that you don't start with loading a unit, that's the most annoying part. Try doing it with gold or something like that at first. Note: You can only save string values, and not other variable types. This is my setup so I got some values I can save in my map.
SavingNow to the real triggering part of the tutorial.We'll use the following script to declare (create) a file variable. Note that the variable is of the type "File" and is named "file".
Now that we got our file variable, we need to make some settings before we can actually start to do stuff.
*file = file name The result will be: Warcraft III/GameData/mapName/file Now we're ready to finally start saving values. We need to set our file variable before we can start with the actual saving though.
After that you simply repeat the process over and over until everything is saved.
LoadLoading the information we've stored use the same method as before with a few changes. We start off just like before.
CreditsNestharus - File I/O |
Last edited: