ID:431162
 
Code:
mob/player/verb/Claim_This_Object(obj/thing in GetClaimList() )

mob/player/proc/GetClaimList()
var list/retList = new()
for ( var/obj/O in view() )
if ( O.isClaimable )
retList += O
return retList


Problem description:

What I want is for the verb to only show up in the popup menu of certain objects.

I am trying to make a proc that decides which objects are valid for use of a certain verb.

The problem is that the verb still shows up on the right click popup menu of every object in view. Also if I try to use the verb on an object without "isClaimable" being set to 1, I get an error:

Sorry, the following is not valid: Tree.0x20016e2
usage: Claim-This-Object obj

In this case I tried it on a Tree object.


Additionally, I only want this verb to be available to certain mobs, which is why I can just have it be a verb of claimable objects.


The problem is that the verb still shows up on the right click popup menu of every object in view.

Take a look at view() / oview() parameters.

Also if I try to use the verb on an object without "isClaimable" being set to 1, I get an error:

Sorry, the following is not valid: Tree.0x20016e2
usage: Claim-This-Object obj


Seems like the variable has no value. Set it to 0 instead.


In response to Blastcore
The default parameters for view() are fine for what I am trying to do, so that is why I'm using it with no arguments.

The variable being unset wasn't causing the bug, it was trying to use the verb on an object that wasn't in the list that "GetClaimList()" returned. I set that variable to be 0 by default for all /obj
Now that i read again your question i understand it better. Well you want only a certain objects to be picked? you could do obj/Pickable and obj/NotPickable and loop though each obj in view() and if the obj is Pickable (You can check using istype())
Unfortunately, I don't think there's any way the client can know what objects are valid (ie returned by GetClaimList()) until one has been selected and it sends it to the server (and then the server checks if it's in the list, and if not, throws back that error).

If this is the only verb you have that has these "special access" rules, you may have better luck defining the verb under the claimable object type, and using set invisibility = 1 to control who can access it. You would then give the mobs who should be able to use it a see_invisible value of 1. If you have multiple verbs that need these limits, but they're always gained in the same order (ie you can have access to A, A&B, A&B&C, but not B without A) you can use increasing values of invisibility.

If that doesn't work for you, the next best alternative may just be to write your own system. You could do it via mouse click, a key press, ect.
EDIT: Nevermind, I understand your question now that I read someone's response who posted before I finished mine. Disregard the below.

GauHelldragon wrote:
Code:
> mob/player/verb/Claim_This_Object(obj/thing in GetClaimList() )
>

Problem description:

What I want is for the verb to only show up in the popup menu of certain objects.

Which means you need to take it out of the mob/player tree. It will be given to all mob/players as it is now. You could also just take the verb from them upon login.
object_verbs/verb/Claim_This_Object(obj/thing in GetClaimList())
mob/Login()
..()
verbs += /object_verbs/verb/Claim_This_Object

Note; This exact code will not work with yours, as you define GetClaimList() under the mob/player tree. It won't know what GetClaimList() is.

OR

mob/Login()
..()
verbs -= /mob/player/verb/Claim_This_Object



I am trying to make a proc that decides which objects are valid for use of a certain verb.

Easy enough. You seem to have that down. Just make a proc, check the parameters you want, and give them the verb if they meet your conditions.

In response to DarkCampainger
Kind of a hack job, but if this is truly the only way to do it, I suppose it will have to do. Fortunately I wasn't using invisibility for anything else, and this is the only verb that operates like this (so far!). I'll give your suggestion a try.
Well, not to offend or anything. But you should make your Help Requests a little more understandable.
In response to Blastcore
This is pretty much exactly what the function I originally posted does. This does not stop the verb from showing up in the pop-up menus of the objects it's not supposed to be in.
In response to Blastcore
It is kind of a difficult problem to explain, I am afraid.
In response to Blastcore
I ended up making the verb invisible. Additionally, I removed it from the verb list of any object for which it was not supposed to use it.