Hello, I'm working on a trigger that you would attach to a room. The object would be a torch. Once you enter the room the room's desc will change by having that (torch) in the room. Anyone present will see the description. Go from being in a pitch black room to "the room is dimly lit" as a description. code that I have tried and I have tried many things other than this
Trying to make (IF) see that I have a torch in inventory
if me.name == "tunnel_torch@examples" <– clearly that didn't work me.send("You see things lit dimly")
by carrying the torch the room changes from dark to light in the description via the me.send, which prob should be ch.send. or this. another modification
if (me.name == tunnel_torch): me.send("You see things dimly")
and error: Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'tunnel_torch' is not defined
tunnel_torch is the object name Anyone know what I'm doing wrong? I do need to define it. I tried making a variable but something wasn't correct in the syntax. Been at this one for hours; all I need to know is what I'm doing wrong… not looking to get razzed thanks.
23 Sep, 2010, David Haley wrote in the 2nd comment:
Votes: 0
If the object name is a string, shouldn't you be putting that in quotes?
1. The first piece of code you posted is missing a colon at the end of line 2. 2. "tunnel_torch@examples" is not the object's name, it is its key and locale. 3. As David pointed out, the object name is a string, so tunnel_torch should be "tunnel_torch" in the second piece of code. 4. As above, "tunnel_torch" is not the object's name, it is its key. 5. Your if statement is essentially saying: if the object's name is X, send the object a message. Objects cannot be sent messages. Even if they could, you seem to want to send the message to the people in the object's room, not the object itself. 6. You are trying to use triggers for something that they are really not designed for. Something this generic should be built into the game engine, not written as a trigger on a per-use basis.
An object's name is something like "a flickering torch", not "flickering_torch@examples". The latter is its key ("flickering_torch") and its locale ("examples"). NakedMud's API documentation suggests that there is no easy way to retrieve an object's key and locale.
chrisd wrote: 1. The first piece of code you posted is missing a colon at the end of line 2. 2. "tunnel_torch@examples" is not the object's name, it is its key and locale. 3. As David pointed out, the object name is a string, so tunnel_torch should be "tunnel_torch" in the second piece of code. 4. As above, "tunnel_torch" is not the object's name, it is its key. 5. Your if statement is essentially saying: if the object's name is X, send the object a message. Objects cannot be sent messages. Even if they could, you seem to want to send the message to the people in the object's room, not the object itself. 6. You are trying to use triggers for something that they are really not designed for. Something this generic should be built into the game engine, not written as a trigger on a per-use basis.
An object's name is something like "a flickering torch", not "flickering_torch@examples". The latter is its key ("flickering_torch") and its locale ("examples"). NakedMud's API documentation suggests that there is no easy way to retrieve an object's key and locale.
I see your meaning, I have changed the quotes and the trigger doesn't show errors now, but that is all null and void anyway now that you say I'm trying to send a message to a object, kinda pointless isn't it :) Yes I want the entire room to see the description change.
So I just need to code a python module not code in c? I see your logic here, I guess it would be better to make modules for this stuff or a module for my custom ideas "mad scientist at work"
From what I understand of what you've said, you're trying to change a room description if an object is in the room; you can do this without triggers using the dynamic room descriptions.
[obj = find_obj("flickering_torch@examples") if obj in room.contents] New description [else] Old description [/if]
Haven't tested that, it's just off the top of my head, but something like that should work.
The problem with using triggers to change the room description is there would be no way to retrieve the old description and it could be confusing to builders trying to edit the room.
NakedMud's API documentation suggests that there is no easy way to retrieve an object's key and locale.
An oversight on my part. In my working copy, objects have obj.proto, which will be part of next release. Currently, you can check obj.isinstance(<key@locale>), and get a comma-separated list of all prototypes inherited from with obj.prototypes, but unfortunately you cannot get the one they directly inherit from.
code that I have tried and I have tried many things other than this
Trying to make (IF) see that I have a torch in inventory
by carrying the torch the room changes from dark to light in the description via the me.send, which prob should be ch.send.
or this.
another modification
tunnel_torch is the object name
Anyone know what I'm doing wrong? I do need to define it. I tried making a variable but something wasn't correct in the syntax. Been at this one for hours; all I need to know is what I'm doing wrong… not looking to get razzed thanks.