ID:2003119
 
(See the best response by Ter13.)
Code:
// So I want to have a verb which can access Player's mob vars
verb/something
world << Stamina

// But how can I make it possible to access Stamina from:
mob/Player/var
Stamina = 1000


Problem description: Is it correct way of thinking of it? I want to use verbs += /verb/something and it works untill I want to access Player's vars in that verb. Can I make this work or there is another way of doing this? Set hidden don't quite make it because they can use these verbs by typing them in or using macro.

mob/verb/Access_Variables()
var input = input(src,"","") in vars | null
world << "[input] = [vars[input]]"


If it's not this, is the path to the verb the same as what path the player(mob) is?
No, I want to make global verbs which I will at some point of the game add to Player's verbs by using verbs += /verbs/something. It works for like
// global space
verbs
Test()
world << "test"
// But I want to access here things like Taijutsu of the player

mob
Player
verb
Rest()
if(Taijutsu > 10)
verbs += /verbs/Test
Best response
Alright, I understand the problem you are running into.

usr is typecast as /mob, not /mob/Player

You will want to create a variable that typecasts usr into the expected type.

// global space
verb
Test()
var/mob/Player/user = usr //this is called typecasting
world << "test"
// But I want to access here things like Taijutsu of the player
world << user.Taijutsu //works use this one
world << usr.Taijutsu //doesn't work
world << usr:Taijutsu //works, but is unsafe

mob
Player
verb
Rest()
if(Taijutsu > 10)
verbs += /verbs/Test
In response to Ter13
Ter13 wrote:
global verb

TIL
In response to Kozuma3
Kozuma3 wrote:
Ter13 wrote:
global verb

TIL


old
Also, I thought I'd throw in another option, which is syntactically correct, but in terms of polymorphism is incredibly stupid.

Most DeeBeeZee/Nartolo/Breach rips handle their hidden verbs like this:

In my case, you have to waste two instructions performing casting in order to access usr which is theoretically just a src alias if you ignore the fact that the type structure on global verbs makes src null.

There's another option, which is to define an uninstantiatable subclass of /mob/Player to house verbs that are hidden from /mob/Player by virtue of being downstream of the inheritance chain.

mob
Player
var
herp
derp
verb
add_test()
verbs += /mob/Player/_verbs/verb/test
verbs += /mob/Player/_verbs/verb/remove_test
verbs -= /mob/Player/verb/add_test
_verbs
verb
test()
world << herp
derp = herp
remove_test()
verbs -= /mob/Player/_verbs/verb/test
verbs -= /mob/Player/_verbs/verb/remove_test
verbs += /mob/Player/verb/add_test


Again though, typecasting is a better option than adding a dummy subtype to act as a verb collection.