In response to O-matic
Then why is it saying list is an undefined proc?
In response to Popisfizzy
Popisfizzy wrote:
Then why is it saying list is an undefined proc?

I dont have a clue O.o. When I copied the code in DM (to test it) and did what I suggested I didn't got any errors, oddly enough...


O-matic
In response to N1ghtW1ng
Options is already a list, so you wouldn't use the list() proc here. Also, using call() with proc name requires the object that owns the proc (in this case, src) be sent as the first argument. Of course, with this setup as soon as anyone Prays everyone will be able to Talk.

Zehlihn
var/list/prayers

Click()
var/list/options=list("Pray")
if(usr.name in prayers)
options+="Talk"
var/action=input("Pick something!") in options
call(src, action)(usr)

proc
Pray(mob/disciple)
disciple << "That was so beautiful that [src] wishes to talk with you now."
prayers+=disciple.name
Talk(mob/disciple)
disciple << "Hello, [disciple]!"
In response to YMIHere
The problem with that is that it adds the usr's name to a list. I don't want it to do that, because after talk, there will be more things, and it will all get very messy.
In response to Popisfizzy
It's probably better to keep the options on the player for saving purposes anyway. Just add Talk to a zeh_options list in the player and use that list in Click().
In response to YMIHere
And what do you mean by a zen_options list?
In response to Popisfizzy
I thought the name started with zen instead of zeh. I changed it. =)
In response to YMIHere
How would I go about doing that? I'm confused by what you mean? :P
[Edit]
I also get this runtime error:<font color = red>
runtime error: type mismatch
proc name: Pray (/mob/mobs/Holy_Beings/Zehlihn/verb/Pray)
usr: Popisfizzy (/mob)
src: Zehlihn (/mob/mobs/Holy_Beings/Zehlihn)
call stack:
Zehlihn (/mob/mobs/Holy_Beings/Zehlihn): Pray(Popisfizzy (/mob))
Zehlihn (/mob/mobs/Holy_Beings/Zehlihn): Click(Grass (36,103,3) (/turf/Environment/Grass/Grass))
</red>
In response to Popisfizzy
You'd keep the list of options available for the player to use on his character. If you plan on having a few of these NPCs with dynamic options you might as well make a nice system for it. =)

mob
var/list/NPC_options // This will be a multi-dimensional list.

proc
GetOptions(NPC_name)
if(NPC_name in NPC_options)
return NPC_options[NPC_name]

AddOption(NPC_name, option)
var/list/options=GetOptions(NPC_name)
if(options)
if(!(option in options)) // We only need one.
options.Add(option)
else
options=list(option)
if(!NPC_options) NPC_options=new // Create it when we need it.
NPC_options[NPC_name]=options

RemoveOption(NPC_name, option)
var/list/options=GetOptions(NPC_name)
if(options)
options.Remove(option)
if(!options.len)
NPC_options.Remove(NPC_name)


dynamic_NPCs
var/list/constant_options // The options an NPC will always have (like Pray from before).

Click()
.=..()
if(get_dist(src,usr) < 2)
var/list/options=constant_options + usr.GetOptions(name)
var/action=input("Blah") as null|anything in options
if(hascall(src, action))
call(src, action)(usr)

Zeh_fella
constant_options=list("Pray")
proc
Pray(mob/clicker)
clicker << "You pray."
clicker.AddOption(name, "Talk")
Talk(mob/clicker)
clicker << "[src]: Hello, [clicker]!"

YMIHere
constant_options=list("Talk", "Shin Kick", "Eye Poke")
proc
Talk(mob/clicker)
clicker << "[src]: Howdy, [clicker]!"
clicker.RemoveOption(name, "Low Blow")
Shin_Kick(mob/clicker)
clicker << "[src]: Ouch!"
clicker.AddOption(name, "Slap")
Eye_Poke(mob/clicker)
clicker << "[src]: Owwie!"
clicker.AddOption(name, "Slap")
Slap(mob/clicker)
clicker << "[src]: Have mercy!"
clicker.AddOption(name, "Low Blow")
Low_Blow(mob/clicker)
del(clicker)


If not, you could just use a list variable (zeh_options) to keep track of what options the player has.

mob
var/list/zeh_options


zeh_guy
Click()
.=..()
if(get_dist(src,usr) < 2)
var/list/options=usr.zeh_options+"Pray"
var/action=input("fv") as null|anything in options
if(hascall(src, action))
call(src, action)(usr)

proc
Pray(mob/clicker)
clicker << "You pray."
if(!clicker.zeh_options) clicker.zeh_options=new
clicker.zeh_options += "Talk"
Talk(mob/clicker)
clicker << "[src]: Hey, [clicker]."
In response to YMIHere
For everywhere you have NPC_name, NPC_options, etc. I have to place in the NPC's name and stuff, right?
In response to Popisfizzy
No, those are variables, you just have to send the right information to those procs. =) The only things you should have to change are the NPCs, like YMIHere and Zeh_fella. If you want to add a new one, you can just do something like this.

mob/dynamic_NPCs
MyNewGuyThatJustSaysHi
constant_options=list("Say hi to me") // This is always available.
proc/Say_hi_to_me(mob/clicker)
clicker << "[src]: hi"


Of course, this guy isn't dynamic at all and really shouldn't use this (it's a waste of a list as it is). To make a good example I should show you how the player's NPC_options list would look like after you played around with the other two NPCs a bit.

mob/NPC_options = list(
"Zeh fella" = list( // The options for Zeh fella
"Talk"),
"YMIHere" = list( // YMIHere's options
"Slap",
"Low Blow")
)


Knowing how this adds up, we can give the player a starting option for a certain NPC, and be able to take it away later (which we can't for with constant options).

mob/var/list/NPC_options=list("Mr. Talk-a-tive"=list("Greet"))  // We can Greet Mr. Talk-a-tive by default.
// Note that I've overridden the initial declaration, you should to if you're testing this out.

// Now we make the guy.
mob/dynamic_NPCs/MrTalkative
name = "Mr. Talk-a-tive"
proc
Greet(mob/clicker) // Default option.
clicker << "[src]: Hello to you to."
clicker.RemoveOption(src.name, "Greet")
clicker.AddOption(src.name, "Talk about the weather")

Talk_about_the_weather(mob/clicker)
clicker << "[src]: Oh, I know. It's simply dreadful!"
clicker.RemoveOption(src.name, "Talk about the weather")
clicker.AddOption(src.name, "Ask for money")

Ask_for_money(mob/clicker)
clicker << "[src]: I hardly know you."
clicker.RemoveOption(src.name, "Ask for money")
clicker.AddOption(src.name, "Say goodbye")

Say_goodbye(mob/clicker)
clicker << "[src]: See you later."
clicker.RemoveOption(src.name, "Say goodbye")
clicker.AddOption(src.name, "Greet")


Now he can be used in a nice looping fashion. Useless? I know, but that's only because I have no need for it. =P You might, if you plan on having other NPCs like your first one. Want a guy that will completely ignore you until you show up wearing the ring he lost?

mob/dynamic_NPCs/guy_who_lost_his_ring
name = "Jed"
proc/I_found_your_ring(mob/clicker)
clicker << "[src]: Wow, thanks! I'd give you a thousand dollars, but I don't know the name of your currency variable or that you use dollars at all. >.>"


Now you'd just call AddOption("Jed", "I found your ring") whenever the player picked up Jed's ring, and RemoveOption("Jed", "I found your ring") whenever the player got rid of it (mob/Entered() and mob/Exited() respectively).
In response to YMIHere
My coding:
mob
mobs
Holy_Beings
Zehlihn
density = 1
icon = 'NPC.dmi'
icon_state = "Zehlihn(Frih/MaleC/Deity)"
constant_options = list("Pray")
Click()
var/list/options = list("Pray")
.=..()
if(get_dist(src,usr)==1)
dir = get_dir(src,usr)
if(usr.firstname in prayers)
options += "Talk"
var/action = input("What do you wish to do?","What do you wish to do?") in options
call(src, action)(usr)
proc
Talk(mob/disciple)
disciple << "How are you?"
spawn(10) dir = initial(dir)
Pray(mob/disciple)
disciple << "[usr.firstname] begins to pray"
spawn(10) dir = initial(dir)
prayers += disciple
Shakra
density = 1
icon = 'NPC.dmi'
icon_state = "Shakra(Frih/FemaleA/Demon)"
Sehlith
density = 1
icon = 'NPC.dmi'
icon_state = "Sehlith(Frih/MaleA/Deity)"
mob
var/list/NPC_Options
proc
GetOptions(NPC_name)
if(NPC_name in NPC_options)
return NPC_options[NPC_name]
AddOption(NPC_name, option)
var/list/options = GetOptions(NPC_name)
if(options)
if(!(option in options))
options.Add(option)
else
options = list(option)
if(!NPC_options) NPC_options = new
NPC_options[NPC_name] = options
RemoveOption(NPC_name, option)
var/list/options = GetOptions(NPC_name)
if(options)
options.Remove(option)
if(!options.len)
NPC_options.Remove(NPC_name)
dynamic_NPCs
var/list/constant_otptions
Click()
.=..()
if(get_dist(src,usr) < 2)
var/list/options = constant_options + usr.GetOptions(name)
var/action = input("Blah") as null|anything in options
if(hascall(src, action))
cal(src, action)(usr)

And I get these errors:
Deities-Gods.dm:38:error:NPC_options:undefined var
Deities-Gods.dm:39:error:NPC_options:undefined var
Deities-Gods.dm:47:error:NPC_options:undefined var
Deities-Gods.dm:47:error:NPC_options:undefined var
Deities-Gods.dm:48:error:NPC_options:undefined var
Deities-Gods.dm:42:if :warning: if statement has no effect
Deities-Gods.dm:54:error:NPC_options.Remove:undefined var
Deities-Gods.dm:8:error:constant_options:undefined var
Deities-Gods.dm:14:error:prayers:undefined var
Deities-Gods.dm:25:error:prayers:undefined var
Deities-Gods.dm:60:error:constant_options:undefined var
Deities-Gods.dm:63:error:cal:undefined proc
Deities-Gods.dm:63:usr :warning: unused label

Its copied exactly, so the lines listed are the actual number.
In response to Popisfizzy
First of all, get rid of the old Click() (the one under Zehlihn). We're not using that anymore. =P Then you have to make Zehlihn a type of /mob/dynamic_NPCs or it won't be able to use the new Click() we made.

As far as the other errors go, you've capitalized the O in the declaration of NPC_options, added an extra t in the declaration of constant_options, un-indented the if segment (if(!(option in options))) in AddOptions(), and left an l off of call() in /mob/dynamic_NPCs/Click(). Also, I left out some stuff in RemoveOption(). It won't cause errors without it, but it should be there.

    RemoveOption(NPC_name, option)
var/list/options=GetOptions(NPC_name)
if(options)
if(options.Remove(option))
if(!options.len)
if(NPC_options.Remove(NPC_name))
if(!NPC_options.len)
NPC_options=null
In response to YMIHere
Ok, it's working finek, thanks. I probably could've figured out the errors on my own, but I was half asleep. :P
Page: 1 2