Act on Another Player
An example of an action which any player in the room can perform on any other player.
[[playerlist]] into the room description (or a detail description). It will show a list of players in the room; each one will be a link. Each link will call
act(idstr), where idstr is the ObjectId of the named player.
The important part of
playerlist is the
link() call, which constructs a function call to
act(idstr). That's simple. It's rather more work to get the commas and "or" right. (Oxford comma!)
act does not display any message to bystanders, only to the two (or one) people involved. Extending this is left as an exercise.
_ls = players.list(location()) _count = len(_ls) _ix = 0 for _pla in _ls: link('act("' + str(ObjectId(_pla)) + '")') if _pla == players.player(): print('yourself') else: print(players.name(_pla)) endlink() _ix += 1 if _ix < _count: if _count == 2: print(' or ') else: print(', ') if _ix == _count-1: print('or ')
act: (Code with argument
_pla = players.player(ObjectId(arg)) if _pla == players.player(): event('You act upon yourself.', text('[$name] acts upon [$themself].')) else: event('You act upon ' + players.name(_pla) + '.') event(players.name() + ' acts upon you.', None, _pla)