ID:142073
 
Code:
mob/verb/Delete(var/obj/T in oview(1))
if(length(T.owner)<=0)
usr << "This object is part of the map! It cannot be deleted!"
return
if(T.owner==src.key)
del(T)
else
usr << "This object is owned by [T.owner]! You can't delete it!"


Problem description:
Trying to use this verb on an object you do not own results in a random object in your view, of the same type as the one you're trying to delete, to be randomly deleted. Unless the object is the only one in your view, in which it will give you the "You do not own this" message.
Mechana2412 wrote:
> mob/verb/Delete(var/obj/T in oview(1))
> if(length(T.owner)<=0)
> usr << "This object is part of the map! It cannot be deleted!"
> return
> else if(T.owner==src.key)
> del(T)
> else
> usr << "This object is owned by [T.owner]! You can't delete it!"


Use else if()'s instead of multiple if()'s.
In response to Andre-g1
And that does anything how? It should only affect preformance of the game, not the code itself.


I just tried that and the bug persists. I made this post to figure out how to fix this bug, not to get comments on my coding structure.
Looks like "owner" is a list. In the second if, you should put "if((key in T.owner))" instead.
Mechana2412 wrote:
mob/verb/Delete()
for(var/obj/T in oview(1))
if(T.owner==usr.key)
del T
else if(!T.owner)
usr << "This object is part of the map! It cannot be deleted!"
return
else
usr << "This object is owned by [T.owner]! You can't delete it!"
In response to Kaiochao
Owner is not a list, it is a text variable that stores the key of the person who created the object.
In response to Andre-g1
That isn't what I'm trying to do. It is supposed to delete a single object that you right-click then Delete.
That's because it just selects one of the type you select. I'm not exactly sure how to fix this besides defining it as an object verb (maybe? I'm not familiar with this problem, though I know it happens). Click() would be a good remedy for this though, because personally, I love the idea of Click() deleting! It just simplifies things...
What happens when you right click it and try to delete it? Does that work? If so, just do this.
mob/verb/Delete()
set hidden=1

to force them to right click it to delete said object.
In response to Quiet Screams
A hidden verb cannot be accessed by the right-click menu.
Because, it's, uh, well... how to explain it. Hidden. =P It must be typed out at the command line to be accessed, and the command therefore has to be known - because it's hidden.
In response to Kaioken
Oh I was thinking of these

invisibility setting (verb)

See also:
hidden setting (verb)
invisibility var (atom)
sight var (mob)

Format:
set visibility = Setting

Args:
Setting: 0 to 100

Default value:
same as invisibility of the source object.

An invisible verb is only accessible to players who can see invisible objects. This is different from a hidden verb which does not clutter up the verb list but which is still accessible when typed in full.

----

popup_menu setting (verb)

See also:
category setting (verb)
hidden setting (verb)
invisibility setting (verb)

Format:
set popup_menu = Setting

Args:
Setting: 1 (default) for showing this verb in the popup menus; 0 otherwise.

Use this to prevent a verb from showing up in the popup "context" menu when users right-click on objects.
In response to Jeff8500
Jeff8500 wrote:
That's because it just selects one of the type you select.

So you experience that too? It may very well be a BYOND bug, I don't see why DS would behave like that when it can send a reference to a specific object just fine, weird...

I'm not exactly sure how to fix this besides defining it as an object verb (maybe? I'm not familiar with this problem, though I know it happens).

That should definitely solve it. If it's not bugged too or something...
turf/verb/Delete()
set src in oview()
usr << "You delete [src]."
del src
In response to Quiet Screams
Woot, DM Reference quirk!

Quiet Screams wrote:
invisibility setting (verb)
[...]
set visibility = Setting

<small>*wonders if -they- will bother with fixing such a small thing*</small>
In response to Kaioken
Input() and the likes (the selection processes) only take names, I think. If X has the name "X", Y has the name "Y", and they are both the same type, it will display both. If they have the same name though, it only displays the name and selects on of them.
In response to Jeff8500
Yes, when you run the verb 'manually', it just chooses whichever with the same name. But when an object verb argument or the src setting (but NOT input(), naturally) is used, you can right-click an object on the map and choose to run the verb on it, and this should always cause DS to send that specific atom you clicked's reference in the verb command. I'm pretty sure it always does this properly in the case of the 'src setting', so if it doesn't for verb arguments (which seems to be what the OP is experiencing and is what you are implying) then it should probably be reported as a bug. I'd look into it and test as such, but school's starting tomorrow and stuff, so I'll leave it to someone else (or to a later time).