Hello,
I was looking through the byond folders on my cousins computer and i found Lummox Jr's incursion folder. Inside was a text file with variables such as adminlist and stuff. I was wondering how this was done. My coding skills are not all that good, but i thought it had sumthing to do with text2file and file2text. Can you help?
[Edit]
Also when you are saving a mob can u only have the savefile type as .sav?
Thanks in advance
ID:176581
Dec 31 2002, 4:26 pm (Edited on Dec 31 2002, 4:32 pm)
|
|
Jan 1 2003, 4:05 pm
|
|
Not to be rude but....Bump.
|
Weedman wrote:
Hello, I used savefile.Export() and Import() for this. The file is deliberately stored in text format so if all else fails it can be edited outside of the game. Lummox JR |
In response to Lummox JR
|
|
Thank you very much. I see how it is done but i have another question. How will i save a list such as a list of admins.lets call it adminlist.
now i tried doing this by just doing F["adminlist"] << adminlist and it returned sumthing like this in the text file adminlist = "MeYouHimHerIt" now how will i make it save so the result looks sumthing like adminlist = list("Me","You","He","She","It") |
In response to Weedman
|
|
Weedman wrote:
Thank you very much. I see how it is done but i have another question. How will i save a list such as a list of admins.lets call it adminlist. Hrm. Can I see the code you're using to set up the original adminlist? If this last line were done before the save line, then it should indeed be saving as a list. Lummox JR |
In response to Lummox JR
|
|
I was lookig at the exporttext var in the DM Help file and there was a string of code attached to it as an example, so i decided to use it.
Here it is: var |
In response to Weedman
|
|
I think I see the problem, and it's fairly insidious, so it's not surprising you didn't spot it.
Basically you're doing everything right; the list is initialized properly, and everything's going along great. However, I kept skipping my eyes back to the AddAdmin verb: mob/host/verb Then it hit me: world/New() When the list is loaded, it's loading as null if you have no file. When += is used on it, the game thinks you want to add text to a blank string, so it becomes a text string matching the first name you put in; the next name you put in gets tacked onto the end of that, because it now thinks adminlist is a string. As you can see this is very, very subtle. The solution to your problem is to add another line after loading the list: F["adminlist"] >> adminlist Alternatively, you can change your AddAdmin verb to re-initialize the list there if it doesn't exist: mob/host/verb Lummox JR |
In response to Lummox JR
|
|
It works! :-D
Thank you very much Lummox. |
In response to Lummox JR
|
|
couldn't you just do
adminlist.Add(t)? |
In response to Hazman
|
|
Hazman wrote:
couldn't you just do That would do the same thing as +=, but with one critical difference: It would actually show up the error of a null list. As a matter of style I much prefer += anyway, though. Lummox JR |