ID:168723
 
Is it possible to have something like:
obj
thingy
Click()
set src in view(1)

I want to have it that if you click on the obj an alert shows up showing the verbs, so there are not so many statpanels. I have tried, but to no avail.
Seems I understood the problem wrong.
In response to Mazoku
This is what I have come up with so far:
mob
Holy_Beings
Zehlihn
density = 1
icon = 'NPC.dmi'
icon_state = "Zehlihn(Frih/MaleC/Deity)"
Click()
set src in view(1)
dir = get_dir(src,usr)
switch(input("What do you wish to do?","What do you wish to do?")in list("Pray To","Talk"))
if("Pray To") spawn() Pray_To()
if("Talk") spawn() Talk()
verb
Talk()
usr << "How are you?"
spawn(10) dir = initial(dir)
Pray_To()
usr << "[usr.firstname] begins to pray"
spawn(10) dir = initial(dir)
In response to Popisfizzy
Um, that dir thing might not work correctly. You might want to try to typepath, or you can try src. I think src is the NPC in this case. You could also use Call() I realized.
In response to N1ghtW1ng
No, the dir works correctly. I would've posted in code problems if that didn't work. But the problem with this coding is that I can click on him from anywhere, and he'll respond.
In response to Popisfizzy
Try this.

mob/NPC/Click()
.=..() // You might need that if you have any other procs that involve Click, and this NPC, if not delete this.
if(usr in oview(src,1))
// Do stuff here


Actually, thinking about it. You can use get_dist also. That might work better.

if(get_dist(src,usr)==1)
// Do stuff here
In response to Popisfizzy
Popisfizzy wrote:
No, the dir works correctly.

it may work correctly but you're doing it uncorrectly.

O-matic
In response to O-matic
Then whats the correct way (don't blame me for it being incorrect, I got it off of the forums. I'm not sure how to do it any other way).
In response to N1ghtW1ng
Okay, that works.

Now I have another question: How would I make it so that "Talk" is added after "Pray To"? I don't want you to talk to the Deity until you've prayed to him.
In response to Popisfizzy
That question got answered before.

O-matic
In response to O-matic
I don't know how to use typepath.
In response to Popisfizzy
Well, you can make a list the NPC holds of people who prayed to him. If the mob prays, then you can add his key/name to the list. Have an if() check which sees if he is in the prayers list. If he is make the switch(input)) include Talk, if he doesn't don't include Talk. I know there is a more complex way to do this by adding to the list() or something, but I really don't know how to do that.
In response to Popisfizzy
N1ghtW1ng wrote:
Um, that dir thing might not work correctly. You might want to try to typepath, or you can try src.

in other words, use "src.dir" :).

O-matic
In response to N1ghtW1ng
I wanted the seconds one. I tried, with no results. The other way could get messy because after that Talk opens up more verbs.
In response to O-matic
K, that works, thanks.
In response to Popisfizzy
Okay, you can do this then:

mob/NPC
var/list/Options = new
Click()
if(get_dist(src,usr)==1)
if(isnull(src.Options))
src.Options+="Prey To"
var/a = input("What do you wish to do","What do you want to do?") in list(Options)
call(a,usr)()
verb/Pray_To()
usr << "You pray'd"
src.Options+="Talk"
verb/Talk()
usr << "You talk"


I didn't exactly test this, there might be a problem with call().


In response to N1ghtW1ng
Inter_Mobs.dm:111:error:list:undefined proc(#1 Error)
Inter_Mobs.dm:112::warning: operation has no effect here(#2 Error)
            Zehlihn
density = 1
icon = 'NPC.dmi'
icon_state = "Zehlihn(Frih/MaleC/Deity)"
var/list/Options = new
Click()
.=..()
if(get_dist(src,usr)==1)
dir = get_dir(src,usr)
if(isnull(src.Options))
src.Options += "Pray"
var/a = input("What do you wish to do?","What do you wish to do?")in list(Options)//#1 Error
call(a,usr)()//#2 Error
verb
Talk()
usr << "How are you?"
spawn(10) dir = initial(dir)
Pray()
usr << "[usr.firstname] begins to pray"
spawn(10) dir = initial(dir)
src.Options += "Talk"
In response to Popisfizzy
            Zehlihn
density = 1
icon = 'NPC.dmi'
icon_state = "Zehlihn(Frih/MaleC/Deity)"
var/list/Options = list()
Click()
.=..()
if(get_dist(src,usr)==1)
dir = get_dir(src,usr)
if(isnull(src.Options))
src.Options += "Pray"
var/a = input("What do you wish to do?","What do you wish to do?")in list(src.Options)
call(a,usr)()
verb
Talk()
usr << "How are you?"
spawn(10) dir = initial(dir)
Pray()
usr << "[usr.firstname] begins to pray"
spawn(10) dir = initial(dir)
src.Options += "Talk"


That should work.
In response to N1ghtW1ng
I'm getting the same errors in the same spots.
In response to N1ghtW1ng
                Click()
.=..()
if(get_dist(src,usr)==1)
dir = get_dir(src,usr)
if(isnull(src.Options))
src.Options += "Pray"
var/a = input("What do you wish to do?","What do you wish to do?")in list(src.Options)
call(a,usr)()


"var/a = input("What do you wish to do?","What do you wish to do?")in list(src.Options)" The problem is with that line, the problem hasn't anything to do with the options thingie (however you did need src in there). You just need to tab it-- it doesn't belong in the middle of an if statement one tab back. The compiler thinks thats the end of that if() statement. but it clearly isn't meant that way because the line under that if() statement is an extra tab, but I'm pretty sure that line is meant to belong to the if() statement.

So the solution is either: tab that var line with the option thingie. Or put that line below the call() proc
Page: 1 2