ID:946833
 
Keywords: code, developer, help, quest
(See the best response by NNAAAAHH.)
So, I have a statpanel called "Inbox", which is where you get letters.
Unfortunately, I can't get the quest giver to put the mail she's supposed to give me in the Inbox tab. It'll go to my Inventory just fine, but I don't want it sent there. How do I have items and mail sent to the Inbox tab?


Code:
mob
npc
Rowena
icon = 'player.dmi'
icon_state = "female"
Click()
alert("Hey, I'm Rowena. I have a gift for you")
rowenaletter = 1
new/obj/mail/Rowenas_Letter(usr.inbox)


These are my Statpanels
mob
Stat()
statpanel(name)
stat(src)
statpanel("Inventory",usr.contents)
statpanel("Party",usr.groups)
statpanel("Inbox",usr.inbox)


And this is the code for the letter

obj
mail
Rowenas_Letter
icon = 'obj.dmi'
icon_state = "mail"
verb
Get()
set src in oview(1)
new/obj/mail/Rowenas_Letter("Inbox")
del src
Open()
set src in oview(1)
icon_state = "mailopen"
src.open = 1
Read_Mail()
set src in oview(1)
if(src.open == 1)
alert("Hey what's up, [usr]. This is your first message. Welcome to Bebop Universe. For more information on how things work, open the HELP tab. See you around. -Raivu")
src.icon_state = "mailread"
else
usr << "You need to open the mail first"
mailopen
icon = 'obj.dmi'
icon_state = "mailopen"
mailread
icon = 'obj.dmi'
icon_state = "mailread"
Mind showing where you define usr.inbox? And what is the purpose of
                Get()
set src in oview(1)
new/obj/mail/Rowenas_Letter("Inbox")
del src
? ("Inbox") contradicts the previous usage.
            Click()
alert("Hey, I'm Rowena. I have a gift for you")
rowenaletter = 1
new/obj/mail/Rowenas_Letter(usr.inbox)

Also, you could condense the Open() and Read_Mail() into a Click(), as I don't see any where where the letter is droped.
I just have "Inbox" set in the Get proc so I can test it without running across the map to try it. Ignore that.
I had defined "usr.inbox" in both the "Get" proc and the location when Rowena is supposed to give me the letter.

I've tried usr.inbox in both parts of the code together and separately, but still no cigar.

With and Without it though, it still won't allow Rowena to put the letter in my Inbox, which I defined as a var so I can use it in my statpanel.

Do you have any other suggestions as to how I can get Rowena to put that letter into my Inbox statpanel?
In response to Raivu
I asked initialy to see where you define inbox.

mob/var/list/inbox=new()
mob
var/tmp
rowenaletter=0
party
groups
inbox

It's in the "var.dm" file instead of the "player.dm" file, where I have my statpanel coded in.

I kept getting errors saying "Inbox" was an undefined var, so I figured I had to code it in as one before I could use it as a statpanel
In response to Raivu
You don't have it set as a list, nor do you have any of the other variables set as a list. Try defining them as list and see how it works.
Ahhh it worked. Thank you so much
Not a problem.
Well, it did work for a minute. I got no errors, but I still go the problem when I loaded it.

Can you show me an example of what you mean?
How would you go about defining Inbox as a var in a list?
In response to Raivu
NNAAAAHH wrote:
I asked initialy to see where you define inbox.

 mob/var/list/inbox=new()
I got that, but where should I put it? In Rowenas Code, as a separate Var, above the Statpanels, etc.
In response to Raivu
Where-ever you need to put it.

mob/var/list/inbox=new()
mob/proc/addLetter(obj/letter/l)
if(!l) return
src.inbox.Add(l)

Also, you shouldn't use usr in Stat(). Sorry for the late catch on that one.
hahaha oh my word, of course!
I never even thought to use Procs to do what I need to do.
Damn, thank you lol.

And I've always been curious but never quite understood, why not use usr instead of src?
I'm trying to pull the Users information, not an object.
In response to Raivu
Stat() is a mob based proc, the src will always be a mob. It's called automaticly. usr tends to be less reliable in procs and should be avoided when posible. You, of course, have to use usr when dealing with a obj's procs if you wish to do something with the mob using it. Or you could call the mob manualy.

usr is the user of the verb/proc. Unreliable inside of most procs.

src is the source of the verb/proc. Always will be unless defined otherwise.

mob/proc //src is a mob
obj/proc //src is a obj
turf/proc //src is a turf
Also, it still won't add the Letter to my Inbox tab.
The code works if I change "inbox" to "user", but it just sends it to my inventory.

Here's what all of my Inventory information looks like.

mob
npc
Rowena
icon = 'player.dmi'
icon_state = "female"
Click()
alert("Hey, I'm Rowena. I have a gift for you")
rowenaletter = 1
new/obj/mail/Rowenas_Letter(src.inbox)
addLetter()


mob
Stat()
statpanel(name)
stat(src)
statpanel("Inventory",src.contents)
statpanel("Party",src.groups)
statpanel("Inbox",src.inbox)

mob/var/list/inbox=new()
mob/proc/addLetter(obj/mail/Rowenas_Letter/l)
if(!l) return
src.inbox.Add(l)

Best response
I appologize, some of the information I have provided is false. I'm tired out at the moment. Stat() is apparently atom and client based, which I did not know. usr is apparently fine to use inside of Stat(), I assume because it's a built-in proc.

BUT, it may be wiser to single out each letter in the person's inbox instead and display it that way.

statpanel("Inbox")
for(var/obj/letter/l in inbox) stat(l,l.name)
In response to Raivu
You shouldn't copy/paste. I wrote that not intending for you to take it, but base yourself around it.
It still wont' work, and I have noooo idea why.
Yup, forget what I just told you it was fairly useless.
In response to Raivu
Raivu wrote:
mob
npc
Rowena
icon = 'player.dmi'
icon_state = "female"
Click()
alert("Hey, I'm Rowena. I have a gift for you")
rowenaletter = 1
new/obj/mail/Rowenas_Letter(src.inbox)//inside Click() src is the NPC, usr is the player. Use usr here.
addLetter()//unneeded and useless with the above