Seltani: Rearranging the gallery

General debates and discussion about the Guild of Writers and Age creation

Re: Seltani: Rearranging the gallery

Postby Acorn » Sun Nov 10, 2013 11:40 am

KathAveara wrote:I second Pavitra's post.


+1 [=3]
Image
Acorn
 
Posts: 724
Joined: Sun Feb 26, 2012 9:56 am

Re: Seltani: Rearranging the gallery

Postby KathAveara » Sun Nov 10, 2013 5:35 pm

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
KathAveara
 
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Postby belford » Sun Nov 10, 2013 10:43 pm

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.
belford
 
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm

Re: Seltani: Rearranging the gallery

Postby KathAveara » Mon Nov 11, 2013 10:31 am

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
KathAveara
 
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Postby belford » Mon Nov 11, 2013 2:26 pm

Right -- code run from a timer, or run directly from an action (a clicked link).
belford
 
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm

Re: Seltani: Rearranging the gallery

Postby KathAveara » Mon Nov 11, 2013 4:34 pm

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
KathAveara
 
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Postby belford » Mon Nov 11, 2013 5:57 pm

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'
belford
 
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm

Re: Seltani: Rearranging the gallery

Postby KathAveara » Tue Nov 12, 2013 10:13 am

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
KathAveara
 
Posts: 79
Joined: Mon Jun 10, 2013 2:29 am

Re: Seltani: Rearranging the gallery

Postby belford » Wed Nov 13, 2013 4:15 pm

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

Re: Seltani: Rearranging the gallery

Postby belford » Wed Nov 13, 2013 4:22 pm

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.
belford
 
Posts: 344
Joined: Sat Sep 29, 2007 7:18 pm

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 11 guests