ID:269632
 
I want to make it that when you click on a mob it sets M to another mob thats in view(1). This is the code im using:

Click(M as mob in view(1))


But it keeps coming up with M set as 'the turf'. Could someone please help me.
Click() doesn't work like that.

I'm not even sure what you're asking, but I'm afraid you can't get click to work with the way you have arguments set up.

Click(atom/a)
if(ismob(a))
var/mob/m=a
var/list/l
for(var/mob/m2 in view(1)) l+=m2
m2-=m
var/mob/MobInOneSpace=pick(l)


I'm not sure if that's what you're looking for, but it does something.

Oh, and you have probably seen people being told not to use ur in procs. I'd just like to point out that usr is safe in Click() and DblClick(), unless you alter usr in client/Click()/DblClick(), in which case usr isn't valid in atom/Click()/DblClick()
Someone just sent me a message and it said error can not find message
In response to Jp
I just found a easier way. I am trying to make it that if a player is next to the football they can pick it up and it goes in there inventory.

mob
Football
icon = 'ball.dmi'
density = 0
Click()
PickUp()
proc
PickUp(M as mob in view(1))
usr << "[M]"
src.loc = M
In response to ADT_CLONE
No. Naughty boy. No put usr in proc.

obj/Football
Click()
if(src in view(1)) Pickup(usr)
Pickup(mob/m)
loc=m


That should work.
In response to Jp
Thanks it worked perfectly
In response to Jp
usr is most certainly fine in Click().
In response to ADT_CLONE
I am now trying to make it so that when you click on another player, If you have the ball it moves into the other players inventory and sets the other players hasball variable to 1. This is the code I thought would work:

obj
Football
icon = 'ball.dmi'
density = 0
Click()
if(src in view(1)) Pickup(usr)
proc
Pickup(mob/m)
loc=m
m.hasball = 1

But it comes up with the error undefined var. Could someone help me.
In response to Airjoe
He had it in is pickup() proc. As a debugging statement, I know, but best not to get into bad habits.
In response to ADT_CLONE
That indentation is off.

You need to define hasball for mobs. So, somewhere in your code, you need these lines:

mob
var/hasball=0


Then, set hasball to one when clicking the ball and moving it into your inventory.

Then you can do this:

mob/Click()
if(usr.hasball&&!hasball)
var/obj/Football/f=locate(/obj/Football) in usr
f.loc=src
In response to Jp
I thought you said usr was bad in procs
In response to ADT_CLONE
Usr is fine in Click() Dont put in...other procs...
In response to Jp
What does this actually do. I dont want it to create a new ball.

Also this error comes up:

runtime error: Cannot modify null.loc.
proc name: Click (/mob/player1/G2/Click)
usr: G1 (/mob/player1/G1)
src: G2 (/mob/player1/G2)
call stack:
G2 (/mob/player1/G2): Click(the turf (1,1,1) (/turf))

This is what I do:

1: Select G1
2:Click ball
3:Click G2 (G2 gets ball)
4:Click G1(selects G1 but doesnt get ball)
5:Click G2(Comes up with this error message