ID:170431
 
this is my first forum post here. i've combed tutorials and faq's and i'm at my wit's end. i'll use a stripped down paraphrased example of the code

i have a list...

var/list/nominees = list()

...that mobs can sign up for once at an npc...

mob/clerk/verb
sign_up(var/mob/M in view(0))
if(M in nominees)
return
else
nominees+=M

an obj has a verb that reads nominee list for mobs and displays them to be chosen from for a vote...

obj/ballot_box/verb
vote()
if(usr.voted==1)
return
else
var/mob/M = input("Vote for...") in nominees
usr.voted=1
M.votes+=1

...but this list is always initially empty of mobs after world/New() (but not i think the text of mob names?)

...on world/Del() the list IS being saved. at world/New() the list IS being loaded. but mobs can still add themselves to list once upon each world load.

i'm thinking the list/nominees is getting redefined as a new list each startup? or the list of mob names is being saved as text perhaps? and when the world is loaded and the list is checked for mobs it ignores what's in list since it's not mobs? the whole 'voting system' works totally fine, except the candidate list after new world startup.

thanks to anyone crazy enough to help. i can send you the actual code if you'd like...
The saving is most likely where you err, but saving in world/Del() probably isn't too wise either. This is my advice:

Save the list as soon as you modify it, for example:
list+=M
var/savefile/F = new("save.sav")
F["list"] << list


When you load the list, do something like this:

var/savefile/F = new("save.saV")
F["list"] >> list
if(!list) list=new/list


That should solve your problem.
In response to HavenMaster (#1)
thanx HavenMaster! That definitely got past that hurdle.

a new one tho... i'm now saving mob.key to the list instead of the mob. but now, whenever a person invokes the vote verb, i get a runtime error upon adding 1 to the input results.votes variable. error says can't read "Ariii".votes i realize this is because the 'votes' var belongs to the mob and not the mob's key.

is there a way to recode to tell the input proc it's picking a mob.key? or some other was to add 1 to the mob's votes var? here's the ballot box...

ballot_box
icon='ballot_box.dmi'
verb
vote()
set src in view(1)
if(usr.voted==1)
usr<<"You already voted!"
return
else
var/N = "Don't Vote"
peeps+=N
var/mob/M = input("Vote for...") in peeps
if(M=="Don't Vote")
usr<<"You decided not to vote."
peeps-=N
else
usr.voted=1
if(!M.votes)
candidates +=1
M.votes+=1
tvotes+=1
usr<<"You voted for [M]."
peeps-=N