ID:484109
 
(See the best response by BrickSquadron.)
I am trying to make it so when the world boots up, it will accsess the world save. Here is what I got so far:

mob/proc/Save_World()
var/savefile/F = new("Saves/World.mat")
src.Write(F)
F["Scoreboard1"] << A_SB
F["Scoreboard2"] << B_SB


mob/proc/Load_World()
var/savefile/F = new("Saves/World.mat")
src.Read(F)
F["Scoreboard1"] << A_SB
F["Scoreboard2"] << B_SB
src << "<font color = green><b>Character Saved.</b></font>"


and here it is when it boots up:

world/New()
world.host << "World Opened"
Load_World()


Error Shows:
Load_World: undefined proc

Best response
Load_World is defined as a mob proc. This means it can only be called by a type of /mob/.

You're trying to call it here from a type of /world/.
I put mob. in front of it and it still doesn't work.
proc/Save_World()
var/savefile/F = new("Saves/World.mat")
src.Write(F)
F["Scoreboard1"] << A_SB
F["Scoreboard2"] << B_SB


proc/Load_World()
var/savefile/F = new("Saves/World.mat")
src.Read(F)
F["Scoreboard1"] << A_SB
F["Scoreboard2"] << B_SB
src << "<font color = green><b>Character Saved.</b></font>"

Should work.
SinMaster1996 wrote:
mob/proc/Save_World()
> var/savefile/F = new("Saves/World.mat")
> src.Write(F)
> F["Scoreboard1"] << A_SB
> F["Scoreboard2"] << B_SB
>
>
> mob/proc/Load_World()
> var/savefile/F = new("Saves/World.mat")
> src.Read(F)
> F["Scoreboard1"] << A_SB
> F["Scoreboard2"] << B_SB
> src << "<font color = green><b>Character Saved.</b></font>"

Small note:
you output(<<) to the savefile in both Save_World & Load_World

Load_World need to be input(>>) from the savefile
mob/proc/Save_World()
var/savefile/F = new("Saves/World.mat")
src.Write(F)
F["Scoreboard1"] << A_SB
F["Scoreboard2"] << B_SB


mob/proc/Load_World()
var/savefile/F = new("Saves/World.mat")
src.Read(F)
F["Scoreboard1"] >> A_SB
F["Scoreboard2"] >> B_SB
src << "<font color = green><b>Character Saved.</b></font>"

In response to Avainer1
Didn't work.

error: mob.Write: undefined var
error: mob.Read: undefined var
it shouldn't be reading it as a variable. Unless you have it like

src.Write = F

or something.
mob.Write(F)
You're trying to use mob as a variable to call Load_World, but you still don't understand the fundamental basics of programming. Mob isn't an instance of an object, it's an object type. You would have to use an instance of mob, not the keyword mob itself, to call your particular functions. Instead of defining these procedures under the mob type, define them under the world type. Then you can call these two procedures from the world type without having to use an instance of the mob type. It makes more sense for the Load and Save_World procedures to exist under the world type anyways. Why would you want any random mob to be able to save and load the world at any arbitrary time?
It would load when the world is booted and save when the world is shut down.

EDIT: I have tried to make it a world proc but when I do that, the Write() and Read() proc are unidentified. So What I want to do is make so that they are called when the world is booted up or shut down. I am aware that I don't understand the fundamental basics of programming, but that's why I ask questions =D.
        Save_Server()
set category="Admin"
if(GMLockCheck())
usr<<"<font color=red>Your admin powers are locked."
return
switch(alert("Are you sure you want to save the entire server?","","Yes","No"))
if("Yes")
for(var/mob/PC/M in world)
if(!M.client)continue
M.client.SaveChar()
sleep(1)
world<<"<font color = gray><u>[servername]:</u> <font color=white>[usr] has saved the entire server!"
EditLog(usr,"Saved the entire server.")

this is the code i use and it works perfectly fine for me