Seltani - detecting players

(If you don’t know what Seltani is then you should make finding out a priority.)

I think what I want is very simple; I just don’t have the syntax. I want a link to respond differently depending on whether a specific player (myself) is in the location. I need to formulate two conditions: “If the actor is the author…” and “Else if the author is in the location…”

It occurs to me that adding special cases that apply only to myself is pretty bizarre, but I need it to avoid locking myself out of stuff.

You can never lock yourself out of stuff, because you can always use the “/eval” debug command to run ad-hoc code (type this in the chat pane) (in your own worlds). So, in an emergency, “/eval move(‘roomname’)” to jump yourself anywhere. Actually, “/move roomname” is sufficient – there are a bunch of debug commands like this.

You can check the actor’s identity like

if player == ObjectId('01234567'): ...

To discover your own player ObjectId, use the “/playstate” debug command.

To check the location of a specific player, I guess you’d do:

if players.ishere(ObjectId('01234567')) and location(ObjectId('01234567')) == location('roomname'): ...

Awesome, thanks!

Note that I will be travelling for the next few days, so answers may be slow. Feel free to ask questions anyway. :slight_smile:

After all these years, I still haven’t gotten this to work. Here’s the text of the property:

[$if player == ObjectId(‘5226a9a06b3d3020bb3d39f7’)]
You’re an employee, so you can [waltz right in|entry].
[$elif players.ishere(ObjectId(‘5226a9a06b3d3020bb3d39f7’)) and location(ObjectId(‘5226a9a06b3d3020bb3d39f7’)) == location(‘527efdeb6b3d301dd38a92d4’)]
The tour guide is right here, so sneaking in is probably not an option.
[$else]
You glance around surreptitiously. You could probably [sneak in|entry].
[$end]

(‘527efdeb6b3d301dd38a92d4’ is the ID of the location in question. Is that what I’m supposed to be using?)

This works fine for me, but anyone else gets an error: “[Exception: players.ishere: must be player or None]” I don’t know what that means.

At some point the second clause just wasn’t triggering at all, and it fell through to letting anybody walk in whether I was around or not, but that version of the code has been lost.

Haven’t tested this, but I’m pretty sure you need to say players.player(ObjectId(‘5226a9a06b3d3020bb3d39f7’)) rather than just ObjectId(‘5226a9a06b3d3020bb3d39f7’).

Similarly, location(ObjectId(‘527efdeb6b3d301dd38a92d4’)) rather than location(‘527efdeb6b3d301dd38a92d4’).

I know this is annoyingly verbose.

That did it, thanks!