ID:176221
 
Ok, I'm trying to make less verb in the panel fro a new game by using the HUD System, I know there's a way to do this, but...I don't feel like having tons of if()'s and else's every where's, when I know there's probably something simpler out there there...ok, here's problem:
I want to make a button called "Talk" where, if you're facing certain mobs...it cals their Talk() verb which is set to hidden. But, it won't allow me to...any ideas or suggestions?
you are calling a verb?

if you aren't putting it in a panel, just define it as a proc!

mob
npc
proc
talk(var/mob/M)
M << "blah blah blah"
return 1

obj
hud
talkbutton
Click()
var/turf/T = get_step(usr.mob,usr.mob.dir)
if(!isnull(T))
for(var/mob/npc/M in T.contents)
M.talk(usr.mob)
return 1
else
return 0

and that should do it! In short, the proc is the same as a verb but it won't show up in any verb panels unless you tell it to. In short, if you are going to manually call a function through general code, it's best to put it into a proc.

I hope this works for you, bye!

[edit] I fixed the hbutton thing, I got it wrong!
Well, first you have to create the basic NPC group, which contains the Talk() proc..
mob/npc
var
dialog
proc
Talk(target as mob)
if(!src.dialog) //Tell them if the NPC doesn't have anything to say.
target << "[src] stays silent.."
else // If they do have dialog, display it to whoever talked to them.
target << "[src] says, \"[src.dialog]\""


Now to create a sample NPC..
mob/npc/Sample_Guy
dialog = "Hello there!"


Now onto the real thing.. The Speak() verb..

mob/verb
Speak()
set hidden = 1
for(var/mob/npc/N in oview(1)) //Return all mobs within one tile
if(get_dir(usr,N)==usr.dir)) // If you are facing a mob near you..
N.Talk(usr) // Call their Talk() proc
else // If you aren't facing one, do nothing.
return


I think that will work. It's not tested. Tell me if it helps.

Ooops, almost forgot. Now just make an object on the hud call this verb, under the Click() proc. Or just make the verb a proc, and call that.

~>Volte

In response to Ter13
well, like I said...I knew all that stuff, but...I wanted something simpler, not pretaining so I have to insert every mob as an if()
In response to Goku72
what do you mean? insert every new mob as an if? just do what the other guy did! give evey mob a dialogue var, and if they do something special , define a new npc sub-type!
In response to Ter13
Yes, but...it's not just "TEXT" it's options...
In response to Goku72
Goku72 wrote:
Yes, but...it's not just "TEXT" it's options...

Then just use this.. I modified my original code that I made for you:
mob/npc
var
dialog
input_dialog = 0
var/list/options = new()
input_dialog_text
var/list/reactions = new()
proc
Talk(target as mob)
if(!src.dialog && !src.input_dialog) //Tell them if the NPC doesn't have anything to say.
target << "[src] stays silent.."
else if(!src.input_dialog)// If they do have dialog, display it to whoever talked to them.
target << "[src] says, \"[src.dialog]\""
else if(!src.dialog)
var/selection = input("[src.input_dialog_text]") in src.options // Make them select an option
var/react = src.options[selection] // Make a var set to the reaction
target << "[src] says, \"[react]\""




mob/npc/Sample_Guy
options = list("Yes"="That's great!","No"="I'm sorry to hear that.") // Selections and answers
input_dialog = 1 // Make it recognized that you need an arguement.
input_dialog_text = "Are you happy?"

mob/verb
Speak()
set hidden = 1
for(var/mob/npc/N in oview(1)) //Return all mobs within one tile
if(get_dir(usr,N)==usr.dir) // If you are facing a mob near you..
N.Talk(usr) // Call their Talk() proc
else // If you aren't facing one, do nothing.
return


Hope it helps you.

~>Volte