Act on Another Player
To the extent possible under law, the person who associated CC0 with this work has waived all copyright and related or neighboring rights to this work.
An example of an action which any player in the room can perform on any other player.
Interpolate [[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.
Properties
playerlist
: (Code):
_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 arg
):
_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)