Author Topic: context %actor.id% in rooms  (Read 10361 times)

0 Members and 1 Guest are viewing this topic.

Offline erwin

  • Sr. Member
  • ****
  • Posts: 314
    • View Profile
context %actor.id% in rooms
« on: August 15, 2014, 11:17:58 am »
There seems to be a small bug (or I'm using the wrong syntax) with context %actor.id% and rooms.

Here's the set up. Suppose I want to store a variable in the room, and my trigger in storing the variables have this line:

Code: [Select]
context %actor.id%
  set myvariable blahblah
  global myvariable
context 0

When players trigger this, statting the room gives

Code: [Select]
myvariable:154:  yes
myvariable:28:  no

i.e. the first player with player ID 154 has stored the value yes in the room, and the second player with player ID 28 has stored the value no in the room.

Now, suppose I want to check the value stored by the respective players, when neither of the players are in the same room.

Code: [Select]
context %actor.id%
set roomnum 75000
if %roomnum.myvariable% == yes
  %echo% yes, %roomnum.myvariable%
else
  %echo% no, %roomnum.myvariable%
endif
context 0

However, this doesn't work as well as it expects.

I have the following cases.

If only ONE player, let's call it player A stores the value yes in the room, this trigger activated by player A will echo yes. Success!

If player A *first* stores the value yes, and player B *then* stores the value no, then player A activating the trigger will trigger a no, and says the value no is stored. Player B activating the trigger will trigger a no, and says the value no is stored.

If player B *first* stores the value no, and player A then stores the value yes, then player A activating the trigger will trigger a yes, and so will player B activating a trigger.

So it seems that the following snippet of code, will give the value of myvariable in that room which has been stored by the last player activating it :(

Thus, I am unsure whether it's a syntax problem, or a small bug.

Motivation for this: Could check if player's action in a room (pulled lever, etc) causes changes in another place (eg gate opens), *only* for the player itself. So if a player spends 20 mins and figures out something, he gets free access, but another player would be stuck.

Could anyone comment on this if they know more? Thanks!

PS. I'll try to pose a workaround to this in the next post.

Offline rynald

  • Administrator
  • Newbie
  • *****
  • Posts: 25
    • View Profile
Re: context %actor.id% in rooms
« Reply #1 on: August 17, 2014, 07:55:41 am »
You're right that there's a bug; only the name of the variable is checked for, not the context. But even when this is fixed, it's not possible to do it in this way because the context of the variable is checked against the context of the script in roomnum, not against the context of the "calling" script.

You could try to do it without using context. In Room A:
Code: [Select]
eval var[%actor.id%] yes
global var[%actor.id%]

and in room B:
Code: [Select]
eval room RoomA
eval t var[%actor.id%]
if %room.varexists(%t%)%
   eval var %%room.var[%actor.id%]%%
   %echo% var = %var%
else
   %echo% no such var
end

Offline erwin

  • Sr. Member
  • ****
  • Posts: 314
    • View Profile
Re: context %actor.id% in rooms
« Reply #2 on: August 22, 2014, 10:40:55 pm »
Yup it works, thanks :)