Gotcha. I need help plugging in the bottom portion

world/New()
..()
global.books = new
if(fexists(save_path))
var savefile/s = new(save_path)
s["books"] >> global.books
world/Del()
var savefile/s = new(save_path)
s["books"] << global.books
..()


Once i have that plugged in i'll go ahead and change to your updated "Write" code.
Okay. I changed the definition from

var list/books = new



TO

var list/books = list("Test Book" = "This is the contents of the book.")


Am i correct in assuming this will leave the test book in the default list?


On second thought- I've changed it back to Var list/books = new
The test book would be left as the default, if books wasn't being set to 'new' inside of world/New().

You don't even really need to initialize it in the definition because it's being initialized when the world loads. In fact, it's actually considered bad practice to initialize your variables at compile-time (as it creates extra overhead when the game starts in the form of init() calls).

In this case having the list initialized in world/New() is probably the best method, but in other cases where the lists aren't global it's usually best to initialize them when they're needed via

if(!my_list) my_list = list()


Before usages of "my_list", and you'd null the list back out when it becomes empty. Most people never bother nulling out a list when it's empty so it'll sit in memory with all of its list struct overhead intact. An empty list still has overhead associated purely from the information associated with it such as length, contents, etc...

This is really only an issue in games where memory usage becomes an issue though, but it doesn't hurt to design with it in mind from the beginning so you don't end up having to redo a ton of code down the road when your game is using way more memory than it should because every mob in the world has a bunch of initialized lists doing nothing. (or something similar to those circumstances)
var list/books = new
var save_path = "worldsaves.sav"
obj/
BookShelves
Click()
var mob/m = usr
var chosen
var information
switch(input(m,"What would you like to do?") in list("Cancel","Read","Write"))
if("Read")
if(global.books.len == 0)
src << "The bookcase is empty."
return
chosen = input(m,"Which book?","Select a Book") in global.books
information = global.books[chosen]
// chosen = Title of the Book
// information = The contents of the book/text.
src << "Reading <u>[chosen]</u>."
src << information
if("Write")
chosen = input(m,"Title?","Title") as text
if(chosen && length(chosen) > 3)
information = input(m,"The title is [chosen].","Contents") as message
if(information && length(information) > 23)
global.books[chosen] = information
world/New()
..()
global.books = new
if(fexists(save_path))
var savefile/s = new(save_path)
s["books"] >> global.books
world/Del()
var savefile/s = new(save_path)
s["books"] << global.books
..()
icon='bookshelf.dmi'
One
icon_state="bookshelf"
density=1
layer=TURF_LAYER+1
Two
icon_state="bookshelf1"
density=1
layer=TURF_LAYER+1
Three
icon_state="bookshelf2"
density=1
layer=TURF_LAYER+1
Four
icon_state="bookshelf3"
density=1
layer=TURF_LAYER+1
Five
icon_state="bookshelf4"
density=1
layer=TURF_LAYER+1


I managed to get the entire thing added with no errors but on my test server after i write a book when i hit read nothing else shows up.
Make sure your test content is more than 23 character long, or it won't be accepted. You also have world/New() and world/Del() in the absolute wrong place and I'm unsure why that compiles without error at all.
LOL oh jeeze. I forgot about the character limit displayed there.

Where should i put World/new() and world/delete()?
They'd be in their own blocks, where 'world' lines up with the leftmost edge of your code editor away from other blocks of code, I'm honestly baffled as to how what you posted compiles (if it even does, I'm sure not testing)
Glad you have it working, I myself prefer to give code instead of a book page worth of text.

People learn different ways and people teach different ways, I'm sure you'll figure out by yourself why and how the code I've given works and from there you can go on to improve it.

The main issue is syntax/formatting that I see, but once you get familiar with existing code I'm sure you'll understand it.

var list/books = new
var save_path = "worldsaves.sav"
obj/
BookShelves
Click()
var mob/m = usr
var chosen
var information
switch(input(m,"What would you like to do?") in list("Cancel","Read","Write"))
if("Read")
if(global.books.len == 0)
src << "The bookcase is empty."
return
chosen = input(m,"Which book?","Select a Book") in global.books
information = global.books[chosen]
// chosen = Title of the Book
// information = The contents of the book/text.
src << "Reading <u>[chosen]</u>."
src << information
if("Write")
chosen = input(m,"Title?","Title") as text
if(chosen && length(chosen) > 3)
information = input(m,"The title is [chosen].","Contents") as message
if(information && length(information) > 23)
global.books[chosen] = information
world/New()
..()
global.books = new
if(fexists(save_path))
var savefile/s = new(save_path)
s["books"] >> global.books
world/Del()
var savefile/s = new(save_path)
s["books"] << global.books
..()

icon='bookshelf.dmi'
One
icon_state="bookshelf"
density=1
layer=TURF_LAYER+1
Two
icon_state="bookshelf1"
density=1
layer=TURF_LAYER+1
Three
icon_state="bookshelf2"
density=1
layer=TURF_LAYER+1
Four
icon_state="bookshelf3"
density=1
layer=TURF_LAYER+1
Five
icon_state="bookshelf4"
density=1
layer=TURF_LAYER+1

This is what i have so far. I get only one error which is this

media\code\turf\Turf.dm:3741:error: proc definition not allowed inside another proc

It selects this line for the error

icon='bookshelf.dmi'
In response to LiquidWhip
Look at what you did: you copy/pasted parts belonging to the BookShelves type to the global namespace.

Glad you have it working, I myself prefer to give code instead of a book page worth of text.

[...]

I agree that everyone learns differently, but giving handouts because it's less time consuming than actually teaching isn't actually helping anyone. The display here is a prime example of this.
In my own opinion.. it helps even less when people spend more time criticizing that method of learning.

Not all people have a problem helping someone learn the best way that works for them. It shouldn't bother anyone that someone was willing to take time out of their day to do this.

Make no mistake it's definitely helping me learn and i'm more than appreciative to Kozuma3 for providing his help. I'm just a single error off of having a system i'll be able to study and learn off of.

Almost there :D
In response to LiquidWhip
You are mistaken and have taken an unnecessary defensive stance.

No one was criticized or judged.

No one is bothered.

I wrote two sentences explaining -- with evidence -- why taking shortcuts only gimps the practitioner.

Take two students attending a school for a given skill: Student A and Student B. Student A is a hard-working, self-applied individual; Student B doesn't take his work as seriously and gets through by copying Student A's work. Both students graduate with the highest scores in their class, but only Student A goes on to be successful. It's simple why this is: Student A applied himself and his mind while Student B was only interested in shortcuts and getting results.

I'd happily admit I'm wrong if so, but I am not. As long as someone is around to spoon-feed you, you won't be interested in learning how to feed yourself.

But hey, don't mind me; continue taking offensive to everything; continue saying you are learning and avoiding self-applied action. Absolutely no skin off my bones, just thought I'd give my 2 cents instead of turning a blind eye like usual (this being the reason why).

Best of luck.
I'm not defensive.Like i said it was just my opinion and one that it seems you can't handle.
I know what helps me learn. Whether or not you choose to believe it is neither here nor there. Continue making assumptions all you'd like.

You're the one who appears to be getting offensive.
Thanks anyway though.
I'm inclined to agree with FKI here, you obviously didn't learn more than how to just smash bits of code in and hope they work. If you had even learned the basics by now you'd know exactly what's wrong with the code you posted above.

I suggest taking a good long look at the DM Guide -- especially the parts about code blocks and how indentation works.
It wasn't a matter of how much i currently know. It was a matter of how much i'm learning about what i didn't already know through this way in example and without a doubt it helps me.

I'm reading the dm guide as well but i still find it a greater help to study an example made.

That's my point entirely though.. I learn better through examples rather than turning down examples that help me. Quite frankly im much more dedicated than given credit for but thats understandable as most people only saw a single screenshot of my game.

I do understand what you're saying but the combination of both is the style i'm comfortable with.
I also feel like people spend more time trying to prove what people dont know rather than helping them. I mean in most cases a person who isnt willing to help in that way would just let someone else help if they wanted to but more often than not people take the time out of their day to tell someone he doesnt know much but frowns on the greater amount of effort it takes to help someone learn through example.

Again .. just my opinion.
You were helped, you took your help and blindly modified it not knowing what you're doing. That's why we discourage just handing out the code with no explanation of what it does, because people just take that code and expect it to do exactly what they asked for, and when it doesn't they try to modify it and end up breaking it even more, causing them to have to come back and ask another question and another and another.

Instead of just detailing what you should have done, providing basic examples of code, and telling you what it does and how, then letting you take that knowledge to make it what you want -- that's the ideal method of learning by example.

Your issue is still a lack of basic understanding of how the language works, no amount of code hand-outs are going to change that.
Welp that's your opinion and you're entitled to it despite the fact that i disagree with it and vice versa.

I mean it's not like people are forced to help.. if they disagree with the form of help asked for there's nothing stopping them from moving along and letting someone else willing to help do so.

I appreciate your concern though
thank you.
It's not an opinion, you can look back on this thread and see that you're failing to grasp the basics. I told you to move world/New() and world/Del() into their own code blocks, you interpreted that as "unindent them to the edge" -- if you had a basic grasp of how the language works you would have known to not only unindent the code, but MOVE it out of the block.

If you don't know what a code block is, read the guide.
In response to LiquidWhip
LiquidWhip wrote:
I mean it's not like people are forced to help..
The guys that try to help people in this section of the forum wish nothing more than to help others understand code. Throughout this thread, you've shown that you don't quite grasp the code given to you by Kozuma. That's fine, but it's also shown you don't understand the basic concepts of the language you're working with--which isn't.

A larger issue I see is you appear to come off as if you're unwilling to try a different approach to learning. That is bad. You tore apart the example and just kept coming back with basic errors you should have at least tried to solve yourself. If you tried, and failed, I don't think you tried hard enough (or wanted to).

Anyway, if after the end of this entire ordeal you've learned anything, or understand the code given to you (and the basics of the language) that's amazing. That's what everyone wants: others to learn.
Page: 1 2 3