ID:148642
 
I'm trying to make a certain verb only appear in your commands tab, if you are near a certain turf, with a certain item in your contents. I thought of doing;
turf my_turf verb Test() if(locate(/obj/my_obj) in usr.contents) set src in oview(1)
But of course, it didn't work, because it would only execute it if I PRESSED the verb. The only other thing I can think of is each time you move, check to see if that turf is near you. I'd appreciate it if someone could help me out of this.

-Rcet
You could create a special area around that turf and check to see if they have the item when they enter the area, if so, add the verb to their verbs. Then, when they leave the area, remove the verb.

~X
For your second question, try something like:

mob
Move()
for(/turf/blah/B in oview())
if(B==/turf/blahspecial)
usr<< "[B] is near you!"



For your First you might consider having the above call a proc.

Good luck, Hope this helps,

~ <font color=darkblue>A<font color=blue>I<font color=3399FF>R <font color=00FFCC>_<font color=00FFFF>K<font color=0099FF>I<font color=blue>N<font color=darkblue>G</font>
In response to Air _King
Air _King wrote:
For your second question, try something like:

mob
Move()
for(/turf/blah/B in oview())
if(B==/turf/blahspecial)
usr<< "[B] is near you!"

There was no second question, and the code you've provided is so riddled with errors as to be useless to anybody. For starters, that should be var/turf/blah/B, not /turf/blah/B. Second, that should be oview(src) at the very least, since usr (the default) isn't really valid in Move(). Third, you didn't indent the if() and its statement under the for() loop, so they're technically not part of the loop. Fourth, B==/turf/blahspecial will always be false because B is a turf, not a type path. Fifth, you don't even need the if() because you can loop through that specific type of turf right in for() anyway, and only need such a type check if you want to catch only that exact turf type and not any subtypes. Sixth, you put in usr yet again, explicitly this time instead of implicitly, and usr is still wrong because it should be src. Seventh, you forgot to call ..() and return its default value, so any time the player tries to move they'll be stuck, and Login() will also fail to place them on the map.

Not to come down on you too hard, but you don't have a clue what you're doing and as such shouldn't be volunteering code to people.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Air _King wrote:
For your second question, try something like:

mob
Move()
for(/turf/blah/B in oview())
if(B==/turf/blahspecial)
usr<< "[B] is near you!"

There was no second question

Yes, there was, he asked how you could see if it was near the mob.

"and the code you've provided is so riddled with errors as to be useless to anybody."

I'm sorry next time ill spend more time.

"For starters, that should be var/turf/blah/B, not /turf/blah/B."

Oops, i was doing a few things at once, i forgot the var sorry.

"Second, that should be oview(src) at the very least, since usr (the default) isn't really valid in Move()."

I learned something new today thanks!


"Third, you didn't indent the if() and its statement under the for() loop, so they're technically not part of the loop."

Sorry, it didnt copy over from the word document right, i figured he could retype it right though.


"Fourth, B==/turf/blahspecial will always be false because B is a turf, not a type path. Fifth, you don't even need the if() because you can loop through that specific type of turf right in for() anyway, and only need such a type check if you want to catch only that exact turf type and not any subtypes."

Again my haste did not pay off, im sorry, next time ill post code ill spend more time reviewing it.

"Sixth, you put in usr yet again, explicitly this time instead of implicitly, and usr is still wrong because it should be src. Seventh, you forgot to call ..() and return its default value, so any time the player tries to move they'll be stuck, and Login() will also fail to place them on the map."

It was just an example i figured he could add it to his normal Move() proc, next time ill be sure to add the whole thing just incase.

Not to come down on you too hard, but you don't have a clue what you're doing and as such shouldn't be volunteering code to people.

I appreciate the constructive criticism and i apologize for my haste and lack of understanding of some parts of my code. I just re-read about the parts you pointed out my errors in and corrected them in the document,

Thanks!