ID:148526
 
mob
var
can = TRUE

client
Center()
if(usr.can)
usr.can = FALSE
usr.Talk()
sleep(1)
usr.can = TRUE

mob
Bengal
icon = 'Bengal.dmi'
proc/Talk()
set src in oview()
if(get_dir(usr,src) != usr.dir)
usr<<"no one there"
return
src.dir = get_dir(src,usr)
usr<<"bengal: dude i rule"

ok, so this is what I have so far for what I am trying to accomplish. What i got here, is bengal is an npc, what i was trying to do was have it so when the .Center macro was called that it would perform the Talk() proc for the bengal. But everytime I Hit .Center, it always says "no one is there" and doesnt turn the direction im facing, i realize that theres a good chance im not calling it on the bengal, but i can't for the life of me figure this out. personally, i wanna set a variable for this talk() proc for each npc, so i could just enter what the npc is saying seperately like

mob
var/saying
Bengal
icon = 'Bengal.dmi'
saying = " I am the man"
proc/Talk()
set src in oview()
if(get_dir(usr,src) != usr.dir)
usr<<"no one there"
return
src.dir = get_dir(src,usr)
usr<<"[saying]"
the way that i want it here is so that when the talk proc is called, it sends the usr a [saying] which what [saying] stands for can be altered for each npc made. i dont know how to set it up so that when the talk proc is called that its directed at the npc and recieved by the pc. If you can help me out here that would be great =)

o and.....

proc/Move_mobs()
for(var/mob/M in world)
if(!M.client)
spawn(rand(10, 20))
step(M, pick(NORTH, EAST, SOUTH, WEST))
spawn(10)
Move_mobs()

world/New()
..()
Move_mobs()

i use this to make my npc's walk, but personally i dont want my npc's to be mobs, and i dont want every one of my npc's walking around so i was wondering if there was a way to alter this proc so i can just call the proc within certain npc's so they will walk randomly instead of calling it at world/New() and instead of for every unoccupied mob in the world
Erdrickthegreat2 wrote:
mob
var
can = TRUE

client
Center()
if(usr.can)
usr.can = FALSE
usr.Talk() <<-----------
sleep(1)
usr.can = TRUE

mob
Bengal
icon = 'Bengal.dmi'
proc/Talk()
set src in oview()
if(get_dir(usr,src) != usr.dir)
usr<<"no one there"
return
src.dir = get_dir(src,usr)
usr<<"bengal: dude i rule"

There's your problem, right there. You're basically calling your own Talk() proc. If you want to call bengal's proc, you'd need to locate him. Either set his tag = name, and have something like var/mob/B = locate("Bengal") or find another way to find him. Then, use B.Talk().

Either that, or define the talk proc to call a talked_to proc in whatever mob is in front of you. Personally, I think that makes more sense, but that's just me.

I'd give some code examples, but it's 2:30am right now, and I have to get up early for work =(
In response to sapphiremagus
thanx sapphire for giving me those pointers, I editted my post while you replied so if you have time tomorrow or something check that out. if anyone else can give me their oppinion or tips or bits of code on the topic im waiting eagerly for your posts
In response to Erdrickthegreat2
It's to late. I'll take a look tommorow, my monitor is starting to go blurry on me again(time for some more coke.)
In response to Jotdaniel
ok well its morning I hope everyone got enough sleep but if someone could help me out on this, this is a real stumper, i'd be very appreciative
One of the problems in your code, perhaps but not necessarily related to your error, is that usr is splattered all over your procs. Generally speaking, it doesn't belong in procs. In client/Center() it's all right because that's actually a verb.

Lummox JR
In response to Erdrickthegreat2
thank you guys for helping me with my walking npc blocker, all i need now is a little help on this..

mob
var
can = TRUE

client
Center()
if(usr.can)
usr.can = FALSE
usr.Talk()
sleep(1)
usr.can = TRUE

mob
Bengal
icon = 'Bengal.dmi'
proc/Talk()
set src in oview()
if(get_dir(usr,src) != usr.dir)
usr<<"no one there"
return
src.dir = get_dir(src,usr)
usr<<"bengal: dude i rule"
this is what i have for an example. I can't figure out how to call the bengals proc. Its really pissing me off and holding me back on my game. if anyone can give me some advice, the index didn't help.
In response to Erdrickthegreat2
Calling Bengal's proc? What proc is that? You haven't given Bengal any procs! The talk proc, by the way you have indented it, belongs to all mobs including the player, not just Bengal.

So, Bengal has the talk proc and you have the talk proc. When -you- hit the center key, why would it call BENGAL's talk proc and not yours?

Center()
var/turf/t = get_step(mob,mob.dir) //Step one... find the square you're looking at.
for (var/mob/m in t) //Are you there, Bengal? It's me, Margaret.
m.talk() //Now we're talking!

Now pressing the center key will look for any mob in the square you're facing, and call THAT MOB's talk() proc. Note that you might want to define a separate type called mob/NPC and have all your NPCs defined that way, then change the for (var/mob/m to for (var/mob/NPC/m, that way you won't have players going around calling each other's talk procs.
In response to Erdrickthegreat2
Nothing else is really gonna be easily fixed until you fix the problem of having usr all over your code, as I already told you. It has no place in most procs, and your Talk() proc appears to be no exception. Replace it with something that does belong there.

Lummox JR
In response to Lummox JR
On this score, I have to disagree... the talk proc the way he uses it is effectively a verb, it's called only in direct response to player input, so the usr is predicatably the player.
In response to Lesbian Assassin
Just so you know, I helped him fix the problem over AIM, he was using a lot more code than he showed.