27 Aug, 2010, thaolen wrote in the 1st comment:
Votes: 0
I am trying to make a door or wall, etc show a general description and not the exit through that door or wall, so I can hide a entrance from members other than Immortals and admins. How can I hide the exit name from members?

It sounds a little confusing I know, but example: The room shows the desc and the hidden area, lets say a torch says when you look at it, "here is a torch burning brightly" to a member that is all they see, but to an imm it shows after an exit or trigger is added, "this torch has an exit behind it". Hard to explain, I don't want members to see the exits in a hidden area or doors that look like a wall. With OLC editor or would that need to be coded with python?
27 Aug, 2010, Mudder wrote in the 2nd comment:
Votes: 0
I would just add this to the look function. Put an if statement in there and if true (they're immortal) then show the appropriate information.
27 Aug, 2010, thaolen wrote in the 3rd comment:
Votes: 0
Hey thanks, easy enough I'll get back to you if I accomplish this.
What is the module name called look? I tried to find it, is this a py module?
28 Aug, 2010, chrisd wrote in the 4th comment:
Votes: 0
There is an easy way and there is a right way to do this. Firstly, 'look' is not a regular command in NakedMUD - it is implemented in C and is not intended to be modified extensively. Instead, it broadcasts a 'look_at_room' hook which functions that display extra information can hook into - there are several such functions in inform.py.

If you go look at the list_room_exits() function in inform.py you will see:

elif ch.cansee(ex):
list_one_exit(ch, ex, dir)


The easy way to prevent invisible exits from showing up is to change the above to:

elif ch.cansee(ex) and (not ex.hidden>0 or ch.isInGroup('wizard')):
list_one_exit(ch, ex, dir)


You then need to put:

me.hidden = 1


In the 'extra code' section of any exit you want to be invisible.

The right way is far more difficult. ch.cansee(ex) should return False if the character can't see the exit. Because NakedMUD is modular, you need to register your own checks to cansee, and by default it will return True unless the character's position is such that they can't see. Unfortunately, the function required to register cansee checks has not been exposed to Python (as far as I can see). You could try exposing it yourself, or see if someone else has. Registering cansee checks is a much, much better way to do this than what I wrote above.

You probably need to extend the OLC to allow you to modify the hidden attribute on objects, too.
28 Aug, 2010, thaolen wrote in the 5th comment:
Votes: 0
I see, and since the time I posted I have found that inform.c does have the look or desc of a room, but I thought there has to be a way to do it in the modules of python, and thus you have proved it. Also the extra code you can enter in any room got me thinking, maybe I could implement that and that would hide the door, but your way sounds better, thanks chrisd.
28 Aug, 2010, thaolen wrote in the 6th comment:
Votes: 0
I did try your python code and it crashed, odd I just need more understanding, at the moment I'm trying to figure out this but all of the answers lie in the c code. Could I do this strictly in Python?
28 Aug, 2010, chrisd wrote in the 7th comment:
Votes: 0
thaolen said:
I did try your python code and it crashed

You made a mistake copying the code in. If you want help, paste the error message, because telling me "it crashed" is useless.

thaolen said:
Could I do this strictly in Python?

Yes. I showed you how above.

EDIT: I said above that you might need to extend the OLC to allow you to edit the 'hidden' attribute on an object. For an exit, setting the 'spot diff' value in the OLC is equivalent to setting the 'hidden' attribute.

EDIT2: Someone just told me that you can register an exit cansee check function with mudsys.register_exit_cansee(func), so you needn't worry about editing the functions in inform.py

mudsys.register_exit_cansee(lambda ch,ex: ch.isInGroup('wizard') or ex.hidden < 1)
28 Aug, 2010, thaolen wrote in the 8th comment:
Votes: 0
Yes that is what I mean about not knowing enough, I'm looking through the reference html index in the folders. No disrespect about your code, I did state I must have done something wrong. And I know, I need to code the OLC parts too but I'm back to the start all over again. thanks for your time.

Quote
EDIT2: Someone just told me that you can register an exit cansee check function with mudsys.register_exit_cansee(func), so you needn't worry about editing the functions in inform.py


very interesting
29 Aug, 2010, thaolen wrote in the 9th comment:
Votes: 0
I have been looking at your code, and attempting to figure it out. I don't know what module the hidden function goes in. What module would it need, a new one?

mudsys.register_exit_cansee(lambda ch,ex: ch.isInGroup('wizard') or ex.hidden < 1)


I think if knew, It would give a better understanding, and I know we talked about OLC code as well.
29 Aug, 2010, Rudha wrote in the 10th comment:
Votes: 0
Hidden is a property of the object. It's defined in the object when it's created. Any of the predefined properties are defined in the actual NakedMud engine.

Rudha/Maya
29 Aug, 2010, thaolen wrote in the 11th comment:
Votes: 0
And what module does the function go in? Are you telling me, if I can get this right. That I need to place that in the extra code part of OLC while editing the MUD?

So just the code in the extra code part of redit should work and make the exit hidden? I don't have a option for singular exits with extra code though.

And I understand about the hidden part.
29 Aug, 2010, chrisd wrote in the 12th comment:
Votes: 0
[quote=[url=/index.php?a=topic&t=3027&p=50058#p50058]chrisd[/url][code=Python]mudsys.register_exit_cansee(lambda ch,ex: ch.isInGroup('wizard') or ex.hidden < 1)[/code][/quote]

That code belongs in a module. It doesn't matter what module, as long as mudsys is imported. Don't put it in the extra code section in the OLC.

Perhaps I wasn't clear enough before: I made a mistake when I said you had to edit the extra code in the OLC. If you want to edit the value of an exit's 'hidden' attribute, go into the OLC and change that exit's "Spot Diff." value.
29 Aug, 2010, thaolen wrote in the 13th comment:
Votes: 0
Thanks chrisd

I have been playing around with the spot diff inside of OLC, what does it do, how does it work? All I can enter is numbers?

And I put your code in inform.py and with mudsys import at the top, no crash too ;)
30 Aug, 2010, chrisd wrote in the 14th comment:
Votes: 0
thaolen said:
Thanks chrisd

I have been playing around with the spot diff inside of OLC, what does it do, how does it work? All I can enter is numbers?

And I put your code in inform.py and with mudsys import at the top, no crash too ;)


An exit's spot diff. (difficulty) indicates how hard it is to see that exit. With the code I pasted above, making the spot diff. greater than 0 will make the exit invisible. You could do something a little more complicated:

import mudsys

def exit_spot_check(ch, ex):
if ch.isInGroup('wizard'):
return True

if ch.hidden == 100):
return False

if ch.skill.spot < ex.hidden:
return False

return True

mudsys.register_exit_cansee(exit_spot_check)


This will make the exit invisible if its spot diff. is 100 but will otherwise check to see if 'ch.skill.spot' (which is something I made up, it doesn't exist) is high enough to let the character see the exit.

Don't use that code. It will raise an error if your characters don't have a 'skill' attribute that returns an object with a 'spot' attribute, and they probably don't. It's just an example of how to add a regular function (rather than a lambda function) as an exit cansee check.

EDIT: Changed -1 to 100.
30 Aug, 2010, thaolen wrote in the 15th comment:
Votes: 0
all right, lol so I go backwards? I was doing above 0 hmm.\
Edit I tried -0 but it would not allow below 0, I am still using your original code
Edit disregard the -0, I see you changed it from -1 to 100
mudsys.register_exit_cansee(lambda ch,ex: ch.isInGroup('wizard') or ex.hidden < 1)


But not your new one, you said I shouldn't use
30 Aug, 2010, chrisd wrote in the 16th comment:
Votes: 0
thaolen said:
all right, lol so I go backwards? I was doing above 0 hmm.


You can do it however you want. Whatever makes sense to you.
30 Aug, 2010, thaolen wrote in the 17th comment:
Votes: 0
Good news, I was able to hide the exit, I took the original code
mudsys.register_exit_cansee(lambda ch,ex: ch.isInGroup('wizard') or ex.hidden < 1)


I made a new module called hide_exit.py and simply put the import mudsys, didn't use a def and added your code

And set the spot diff to 100 and now my test char can't see the exit.

thanks again chrisd

Now If I could just do these things myself, it would certainly give me a feeling of accomplishment.
0.0/17