Act on Another Player

From Seltanikor
Jump to navigationJump to search

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.


playerlist: (Code):

   _ls = players.list(location())
   _count = len(_ls)
   _ix = 0
   for _pla in _ls:
       link('act("' + str(ObjectId(_pla)) + '")')
       if _pla == players.player():
       _ix += 1
       if _ix < _count:
           if _count == 2:
               print(' or ')
               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].'))
       event('You act upon ' + + '.')
       event( + ' acts upon you.', None, _pla)