ID:1372149
 
(See the best response by FKI.)
Code:
obj
BookOfFire
icon = 'Objects.dmi'
icon_state = "BookOfFire Level 1"
verb
readbook()
set name = "Read Book"
set src in view (1)
usr<< "You being reading Chapter 1..."
sleep (20)
usr<< "You finish reading Chapter 1..."
usr.exp += 10
usr.firelevel += 1
usr.LevelUp()
src.contents += new/obj/BookOfFire_Lvl2
del /obj/BookOfFire


BookOfFire_Lvl2
icon = 'Objects.dmi'
icon_state = "BookOfFire Level 2"
verb
readbook()
set name = "Read Book"
set src in view (1)
usr<< "You being reading Chapter 2..."
sleep (20)
usr<< "You finish reading Chapter 2..."
usr.exp += 10
usr.firelevel += 1
usr.LevelUp()
del src



Problem description:
I want this book of fire to go from chapter one to chapter two and each chapter gives you plus one skill level. But when i run the verb i get this runtime error.

You being reading Chapter 1...
runtime error: bad del
proc name: Read Book (/obj/BookOfFire/verb/readbook)
usr: Guest-148665090 (/mob)
src: BookOfFire (/obj/BookOfFire)
call stack:
BookOfFire (/obj/BookOfFire): Read Book()
You finish reading Chapter 1...

Help? I just want to know if what i'm doing is possible or if i need a new system. Thanks in advance.

Link.
del /obj/BookOfFire


That's your problem. I think you want del(src).
Thank you, that deleted the first book but now i want to add Book of fire lvl 2 but it never gets put in the inventory.

im doing
src.contents new/obj/BookOfFire_Lvl2
EDIT:
src.contents += new/obj/BookofFire_Lvl2
Best response
I'm pretty sure new/obj/BookofFire_Level2(usr) would suffice. Or if you just changed src.contents to usr.contents, as src is the book in this case, and usr is whatever used the verb (you, me, etc).
Yeah, That was the problem all along. Its always the simple things, but thanks FKI. :D
You may want to add in some way to stop players from spamming the readbook() verb. As you have a sleep(20) in there, you can use the verb several times before the object is deleted.
Well I see your problem is solved, but I wouldn't define a new book for every single chapter. I'd do it this way instead:
obj
Book
var/chapter = 1
proc/read()
world << "You are reading Chapter [chapter]"
sleep(20)
world << "You finished reading Chapter [chapter]"
chapter += 1
name = "Book (Chapter [chapter])"

This way you have infinite chapters and don't have to code so much :)
Yea i see where that makes it easier and i will do that for other things, but each chapter adds +1 skill level.... oh wait i can still do that with this xD. Thanks Balborg lol.