ID:148324
 
Ok basically I'm trying to log any GM activity. It's storing a small string in a list var (GMLog) and saves it when the world is shutdown (or every 5 minutes, when WorldTick() occurs). Anyway, my problem is it doesn't seem like its saving! Either that or its not loading...but either way its not working. And all of the other saving pieces work perfectly. It saves and loads the banned list, team data, etc. but not the GMLog list for some reason. Anyway, here's the code...if anyone knows what's going on, it'd be appreciated :)

var/list/GMLog
world
name = "The Fast and the Furious"
mob = /mob
hub = "Ghaleon.TheFastandtheFurious"

New()
..()
InitFilter() // Sets up spam filter
var/savefile/D = new ("data.sav")

D["logged"] >> GMLog
D["banned"] >> banned
D["donators"] >> donators
D["Name"] >> TeamName
D["EWon"] >> TeamEWon
D["ELost"] >> TeamELost
D["TWon"] >> TeamTWon
D["TLost"] >> TeamTLost
D["MemberCount"] >> TeamMemberCount

if(isnull(GMLog))
GMLog = new/list
if(isnull(banned))
banned = new/list
if(isnull(donators))
donators = new/list
if(isnull(TeamName))
TeamName = new/list
if(isnull(TeamEWon))
TeamEWon = new/list
if(isnull(TeamELost))
TeamELost = new/list
if(isnull(TeamTWon))
TeamTWon = new/list
if(isnull(TeamTLost))
TeamTLost = new/list
if(isnull(TeamMemberCount))
TeamMemberCount = new/list
WorldTick()

Del()
SaveFilter()
var/savefile/D = new ("data.sav")
D["logged"] << GMLog
D["donators"] << donators
D["banned"] << banned
D["Name"] << TeamName
D["EWon"] << TeamEWon
D["ELost"] << TeamELost
D["TWon"] << TeamTWon
D["TLost"] << TeamTLost
D["MemberCount"] << TeamMemberCount
..()

proc/WorldTick()
sleep(3000)
var/Display = rand(1,3)
switch(Display)
if(1)
world << "\blue ---{Don't forget to vote for the game on Byond100}---"
if(2)
world << "\blue ---{Just because I'm feeling generous, everyone gets $5!}---"
for(var/mob/M in world)
if (M.client)
M.Cash += 5
if(3)
var/Num
for(var/mob/M in world)
if (M.client)
Num++
world << "\blue ---{Wow...there are only [Num] people in here. Invite your friends to play!}---"
var/savefile/D = new ("data.sav")
D["logged"] << GMLog
D["donators"] << donators
D["banned"] << banned
D["Name"] << TeamName
D["EWon"] << TeamEWon
D["ELost"] << TeamELost
D["TWon"] << TeamTWon
D["TLost"] << TeamTLost
D["MemberCount"] << TeamMemberCount
WorldTick()

/mob/God/verb
ViewGMLog()
set category = "GoD"
usr << "--- GM Log ---"
for (var/I in GMLog)
usr << "[I]"

GetCar(var/C as anything in typesof(/obj/car))
set category = "GoD"
var/obj/Car = new C
Car.loc = usr
GMLog.+= "[time2text(world.realtime, "MMM DD hh:mm YYYY")] - [usr] Got car: [Car]"
</<></<></<></<></< ></<></<></<></<>
Ghaleon wrote:
if(isnull(GMLog))
GMLog = new/list

Hmm...maybe this could be a possible problem, you defined it as a list, soo maybe...it's not reading the list as anything is added. instead of if(isnull(GMLog), try:
if(!GMLog.len)
GMLog=new()
In response to Dracon and Goku72
Hmm...maybe this could be a possible problem, you defined it as a list, soo maybe...it's not reading the list as anything is added. instead of if(isnull(GMLog), try:
if(!GMLog.len)
GMLog=new()

Nope, no dice. The problem with that is you're checking the length of something that technically doesn't exist (because its not created with the new() proc yet). I even tried making the file first, with GMLog data in it, and then loading it with no checks, and that didn't work either. My guess is there's something wrong with my saving...but I can't figure out what in god's name is going on here. I'm so confused...lol
First of all make a SaveData() proc so you're not copying and pasting code all over the place only to have 4 places to change whenever you need a change to one of them. Also I don't know if you can output a log to a file. I save logs like:

var/savefile/F = new("stuff.txt")
var/list/L[]
//Create and add a bunch of stuff to L
F << length(L)
for(var/i = 1; i <= length(L); i++)
F << L[i]


// Then to load you'd do
var/entries
var/tempentry
var/list/L[] = new()
var/savefile/F = new("stuff.txt")
F >> entries
for(var/i = 1; i <= entries; i++)
{
F >> tempentry
L.Add(tempentry)
}

In response to Theodis
I know you can save a list to a file. How? You see all those other things below the place I read/write the GMLog var? All but 2 are lists, and they all work perfectly. Oh and the saving of these vars is only in 2 places for now, I wanted to make sure it wasn't just a single proc that's causing all the trouble.

I said it was odd ;P
In response to Ghaleon
I said it was odd ;P

That's why you should try the brute force method to see if it's the list saving that's cauing the problems :P.
In response to Theodis
Alrighty. I'll give it a try and save it item by item :)

[EDIT] YAY! Thanks for the help Theodis. I still can't help but wonder why it wouldn't save that list, but oh well. It works, and I'm happy.[/EDIT]