Stuck on how to make/implement a lock that requires code/psw

Asyranok
21 Feb 2013, 21:43
Does anyone have any examples or advice on how I would set up a lock that requires the user to enter a code, such as 555444. Then, this code is interpreted as an integer which is compared to an attribute with a value. If the entered code matches the input code from the player, then the door is unlocked.

I can't find any examples and I'm completely stuck. I saw something about IsInt() but I tried it and couldn't get it to work. Even if I did know what function or code to use, I probably wouldn't know how to correctly implement it.

Thanks ahead of time for any advice!'

As an added bonus of frustration, I am stuck on how I would implement code to make a conversation become visible because someone Looked At an object.

So, right now, if I don't want a conversation to be available at the start of the game, I have to choose "Conversation Topic" rather than "Starting Conversation Topic". I can choose a topic that, once talked about, introduces another topic that is simply a "Conversation Topic".

But I want the "Conversation Topic" to be activated and available because a person looked at a certain object, not by talking about something previous in a string of dialogue. How would I even start doing something like that?

TriangleGames
22 Feb 2013, 02:00
If you looking to have the player enter raw input for the password
(as opposed to choosing from a list of potential passwords, for instance),
I can tell you a simple way to do it in the gui, but it doesn't use any "fancy" dialog boxes or anything. So I would recommend you start with Clear Screen and end with Wait, just to make it more obvious to the player what is happening. It would look like this:
(player enters, "use keypad," or whatever you have to initiate the password entry)
Run Script:
—Clear the Screen
—Print(centered) message: ENTER PASSWORD
—Get input, then run script:
——If: expression: result="123456" //This would be the only place you need to define the correct password.
——Then:
———Print (centered) message: PASSWORD ACCEPTed, ACCESS GRANTED
———Unlock exit: your exit
——Else If: Nothing
——Else:
———Print (centered) message: ACCESS DENIED, SECURITY NOTIFIED . . . //Or whatever the consequence of a wrong password would be.
—Wait for key press, then
——whatever happens next

EDIT: Answer to Second Question
It looks to me like you're using the Conversation Library, which I'm not really familiar with. However, I believe I have found the explanation you're looking for in the documentation, here:
http://quest5.net/wiki/Dynamic_Menus_for_Conversations
Again, I understand it better in the gui than the code right now, but the 3rd screen shot under the Topics header shows an example of showing a hidden conversation topic after taking an object. It should work just as well for looking at one.
The script you are looking for in the script menu is labeled "Run an object's script attribute."
According to the wiki, that should do the trick.

Asyranok
22 Feb 2013, 04:38
Thanks, Triangle. That worked. I was over-complicating things.

I haven't tried the conversation thing yet, but that looks like exactly what I need. I'll let you know if that all works.

HegemonKhan
22 Feb 2013, 10:40
If you still need help, let me know, and I'll help you.

there's a noob thread already on conversations, though I can't remember what the thread was called, but I answered about conversations in that thread, and here's a code that I did for it (ah, this was for dwn, hehe):

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
<hint_list type="list">null_hint</hint_list>
<autodisplayverbs type="boolean">false</autodisplayverbs>
<pov type="object">player</pov>
<start type="script">
character_creation
</start>
<hint_dict type="scriptdictionary">
<item key="doormat_hint">
msg ("Try to pull the doormat. Type in: pull doormat")
</item>
</hint_dict>
</game>
<object name="homeyard">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="editor_player" />
<drop type="boolean">false</drop>
<displayverbs>Look at</displayverbs>
<inventoryverbs>Look at; Use; Drop</inventoryverbs>
</object>
<object name="guide">
<inherit name="editor_object" />
<drop type="boolean">false</drop>
<displayverbs>Look at; Hint</displayverbs>
<inventoryverbs>Look at; Use; Drop</inventoryverbs>
<hint type="script">
show menu ("Hint about what?", game.hint_list, false) {
switch (result) {
case ("null_hint") {
msg ("No hints are available")
}
case ("doormat_hint") {
msg (ScriptDictionaryItem (game.hint_dict,"doormat_hint"))
}
}
}
</hint>
</object>
<exit name="to_frontyard" to="frontyard" />
</object>
<object name="frontyard">
<inherit name="editor_room" />
<object name="doormat">
<inherit name="editor_object" />
<drop type="boolean">false</drop>
<displayverbs>Look at</displayverbs>
<pull type="script">
MakeObjectVisible (frontdoorkey)
msg ("You found a key under the doormat")
</pull>
<look type="script">
list add (game.hint_list, "doormat_hint")
msg ("Your guide has a new hint for you now")
</look>
</object>
<object name="frontdoorkey">
<inherit name="editor_object" />
<alias>key</alias>
<drop />
<take />
<visible type="boolean">false</visible>
</object>
<exit name="to_homeyard" to="homeyard" />
</object>
<turnscript name="game_turns">
<enabled />
<script>
if (frontdoorkey.parent = player) {
msg ("You've won the game!")
finish
}
game.turns = game.turns + 1
</script>
</turnscript>
<verb>
<property>hint</property>
<pattern>hint</pattern>
<defaultexpression>"You can't hint " + object.article + "."</defaultexpression>
</verb>
<function name="character_creation">
msg ("What is your name?")
get input {
player.alias = result
msg (" - " + player.alias)
show menu ("What is your gender?", split ("male;female",";"), false) {
player.gender = result
show menu ("What is your race?", split ("american;european;african;asian",";"), false) {
player.race = result
show menu ("What is your eye color?", split ("blue;green;hazel;amber;brown",";"), false) {
player.eye_color = result
show menu ("What is your hair color?", split ("yellow;orange;red;brown;black;grey;white",";"), false) {
player.hair_color = result
show menu ("What is your skin color?", split ("white;light;tan;dark;red;brown;black",";"), false) {
player.skin_color = result
show menu ("What is your maturity?", split ("adult;teen;child",";"), false) {
player.maturity = result
msg ("What is your age?")
get input {
player.age = result
msg (" - " + player.age)
msg (player.alias + " is a " + player.age + " year old " + player.gender + " " + player.race + " " + player.maturity + " with " + player.eye_color + " eyes, " + player.hair_color + " hair, and " + player.skin_color +" skin.")
wait {
ClearScreen
}
}
}
}
}
}
}
}
}
</function>
</asl>


------

and here's the link for the wiki guides:

http://quest5.net/wiki/How_to

the dynamic conversation is but one of these guides.

Asyranok
22 Feb 2013, 18:50
Thanks Hegemon. I think I finally grasped it.