ID:2252311
 
(See the best response by Kaiochao.)

obj
LittleRootTown
PokeBalls
icon='Objects.dmi'
icon_state="pokeball"
var/PokemonToGive
verb/Interact()
set src in oview(1)
set popup_menu=0
set hidden=1
if(usr in Oview(1,src))
else return

proc/Oview(var/dist, var/atom/A)
var/list/objects = oview(dist, A)
for(var/object in objects)
var/dir_to = get_dir(src,object)
if(dir_to & dir_to - 1)
objects -= object

return objects



i'm trying to make the player interact with one of the pokeballs by pressing z
but when i press z this menu opens up with all the pokeballs and im trying to only let the player interact with the one directly in front of him, how do i do that?
If this is pixel movement try using obounds() which checks the number of pixels instead of a tile of 32x32 (or 16x16, if thats the icon size in your game), It's more precise.
In response to Kidpaddle45
i am not using pixel movement
Best response
It looks like you want an "Interact" verb that works on an interactive object in the tile in front of the player.

Since your object's Interact verb has "set src in oview(1)", the verb is accessible to any player if "src in oview(1)", if the object is visible within 1 tile of the player and isn't in the player's contents. So, this isn't what you want. It would be nice if you could do "set src in get_step(usr, usr.dir)", but unfortunately that's not an option.

Here's how I would do it:
// use whatever your player mob type is.
player
verb
// it takes no arguments because it looks for the target.
Interact()

// get the turf in front of src (src is the player mob).
var turf/front = get_step(src, dir)

// iterate over objs in front of the player.
for(var/obj/target in front)

// check if the target has an Interact proc.
if(hascall(target, "Interact"))

// call the target's Interact proc
// with src as the first argument.
call(target, "Interact")(src)

// break the loop so it doesn't continue to the next obj.
break

// otherwise the loop continues to the next obj.

// and here is the Interact proc you would want instead of your verb
obj
LittleRootTown
PokeBalls
proc
// this proc defines what the pokeball does when it's interacted with.
// take a player mob as the argument
// (change the type to your player mob's type).
Interact(player/player)
// src is the pokeball.
// "player" is the player interacting with src.
// do not use usr, there is no need for it.
In response to Kaiochao
yet again you've solved my problems thank you
In response to Kaiochao
call()() is inefficient, since you've already done the hascall() check you can just do target:Interact(src) instead of call()()