+1 [=3]KathAveara wrote:I second Pavitra's post.
Seltani: Rearranging the gallery
-
- Posts: 79
- Joined: Mon Jun 10, 2013 2:29 am
Re: Seltani: Rearranging the gallery
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
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon
Grand Master of the Guild of Linguists
Re: Seltani: Rearranging the gallery
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.
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.
-
- Posts: 79
- Joined: Mon Jun 10, 2013 2:29 am
Re: Seltani: Rearranging the gallery
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
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon
Grand Master of the Guild of Linguists
Re: Seltani: Rearranging the gallery
Right -- code run from a timer, or run directly from an action (a clicked link).
-
- Posts: 79
- Joined: Mon Jun 10, 2013 2:29 am
Re: Seltani: Rearranging the gallery
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
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon
Grand Master of the Guild of Linguists
Re: Seltani: Rearranging the gallery
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'
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'
-
- Posts: 79
- Joined: Mon Jun 10, 2013 2:29 am
Re: Seltani: Rearranging the gallery
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
DI KI: 00205116
deviantART: kathaveara
tumblr: kaththedragon
Grand Master of the Guild of Linguists
Re: Seltani: Rearranging the gallery
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:
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.
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)
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.
Re: Seltani: Rearranging the gallery
Here's a non-buggy version:
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.
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 = []
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.