Seltani: Rearranging the gallery

General debates and discussion about the Guild of Writers and Age creation
Post Reply
Acorn
Posts: 724
Joined: Sun Feb 26, 2012 9:56 am

Re: Seltani: Rearranging the gallery

Post by Acorn »

KathAveara wrote:I second Pavitra's post.
+1 [=3]
Image
KathAveara
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Post by KathAveara »

Question: How do I make an on_enter (this location can only be entered via linking) call a move()? I've tried this with a move() I know works, but it does not invoke.
Moula KI: 17967159
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon

Grand Master of the Guild of Linguists
belford
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm
MOULa KI#: 0
Contact:

Re: Seltani: Rearranging the gallery

Post by belford »

Good question, and I should have thought of this when you first mentioned your move-on-enter setup.

The hooks currently don't allow movement. This is to prevent infinite loops -- on_enter triggering move triggering on_enter, etc.

If you want the Age's entry point to be variable, right now the only option is to build an antechamber. (Link in to the antechamber, then click on an action which moves you to the desired point. Or you might set up a short timer to auto-move the player, but that's got the one-second minimum.)

I realize this may not fit into your design, in which case I can only apologize. A portal with a computed destination is a possible future feature, but it won't happen in the next two weeks.
KathAveara
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Post by KathAveara »

I've already got the code working to transport you to a variable destination, but ideally it would automatically activate. So, I can do that only if I used a timer?
Moula KI: 17967159
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon

Grand Master of the Guild of Linguists
belford
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm
MOULa KI#: 0
Contact:

Re: Seltani: Rearranging the gallery

Post by belford »

Right -- code run from a timer, or run directly from an action (a clicked link).
KathAveara
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Post by KathAveara »

Using sched() inside on_enter isn't working with my move() code.
Moula KI: 17967159
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon

Grand Master of the Guild of Linguists
belford
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm
MOULa KI#: 0
Contact:

Re: Seltani: Rearranging the gallery

Post by belford »

Then you have some other bug in your code.

I know that debugging timer code is difficult, since you don't get any error messages. This may improve eventually but for the moment you just have to be careful.

I can see a couple of timer-caught errors in the logs:

[W Nov-11 17:40:33: commands:355] Caught exception (timer event): Name "pumplist" is not found
[W Nov-11 20:38:24: commands:355] Caught exception (timer event): 'No such location: foot'
KathAveara
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Post by KathAveara »

None of mine. I know the timer itself works, since I used it to trigger another code property containing an event(). For that matter, I could do it without the timer; calling that property direct from the on_enter hook worked just fine. However, as soon as I tried to get it to call a different code prop, nothing.
Moula KI: 17967159
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon

Grand Master of the Guild of Linguists
belford
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm
MOULa KI#: 0
Contact:

Re: Seltani: Rearranging the gallery

Post by belford »

Okay, I got a chance to test this case.

The problem turns out to be that in a timer event, there is no current location and no current player. So you need to pass a player argument to move().

I was able to sort of get the right effect this way:

Code: Select all

# on_enter property (code):
realm.tempplayer = ObjectId(player)
sched(1, timerfunc)

# timerfunc property (code):
_player = players.player(realm.tempplayer)
realm.tempplayer = None
event('You are moved.', player=_player)
move('locname', player=_player)
Obviously this is not ideal either! For one thing, if two people link in within a second of each other, realm.tempplayer will be overwritten -- one of them will be moved twice, the other one not at all. If *16* people link in within a second of each other, this will hit the limit on the number of simultaneous timers.

There's also the case where the player links out less than a second after linking in. The move() call will then fail with an exception ("Player is not in the current instance"), although again, this message will vanish into the log files where you can't see it.
belford
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm
MOULa KI#: 0
Contact:

Re: Seltani: Rearranging the gallery

Post by belford »

Here's a non-buggy version:

Code: Select all

* on_init property (code)
realm.templs = []

* on_enter property (code)
if not realm.templs:
    sched(1, timerfunc)
realm.templs.append(ObjectId(player))

* timerfunc property (code)
for _id in realm.templs:
    _player = players.player(_id)
    if players.ishere(_player):
        event('You are moved.', player=_player)
        move('place3', player=_player)
realm.templs = []
Now there can be no more than one timer running at a time; it handles a list of players. Note that the on_init hook creates a instance property of an empty list. (A world-defined empty list would be immutable.)

Clearly this is more work than it should be. It argues for the following features, already on the to-do list:

- Timer code arguments. Should be able to pass a player value to each timer call. (Since timers are not stored in the DB, this would also avoid the ObjectId dance.)
- A way to call code with "the current player" set to a particular player.

And since this is all a way to do a "computed in-link", that should be a feature in its own right. I'll write it up, although it's a lower priority.
Post Reply

Return to “General Discussion”