Use/ give doesn't seem to work

Davidmarks
18 Dec 2015, 16:25
I am trying to set up the unlock door with a security code as shown in the help file, If I type in the words “Use keypad” it works OK. But unless I take the keypad (I would rather leave it on the wall !) it does not offer me the use verb. Then when I do take it and click on use it simply replies ”You can’t use it that way “ can someone please tell me why ?

OurJud
18 Dec 2015, 17:25
Don't make it an object, and add a custom command to the room, which runs a script to do as you desire. The best thing about using a custom command is that you can have a huge rage of possible commands that the player might use: use keypad; open door with keypad; etc etc.

Even if you do set it as an object, just set it to 'can be used on its own' and then you shouldn't need to 'take' it before you can use it.

I hardly use any of the pre-defined functions for objects, etc. They can all be used just as you please with command scripts.

Davidmarks
18 Dec 2015, 23:02
Thanks for that. I haven't figured out this custom command business, but it sounds important so I'm working at it !

OurJud
18 Dec 2015, 23:54
I wouldn't say they're important, David, just that they're very often my 'get out of trouble' solution.

I think I need to explain that my advice and solutions should always be viewed as a fall-back, as there are far better coders and scripters here who will explain the correct way to do something.

For what it's worth, here's how I would do a keypad entry:

First let me say the only reason I would have the keypad as an object is so that the user gets a response for 'x keypad'.

So, right click on the room where your keypad is, and pick 'Add Command'.

In the first field, under 'Command pattern', add a list of commands the user might type, separated by a semi colon. i.e. use keypad; use keypad to enter room; enter code; so on and so forth.

Now, where it says, 'Script', click the second icon from the right (looks like a sheet of paper with writing on it), and add the following code in the field that appears:

msg ("Enter password")
get input {
if (result="123456") {
MoveObject (player, room 2)
}
else if (result="reject") {
ShowRoomDescription
}
else {
msg ("Incorrect password.")
do (UseKeyPad, "script")
}
}


Change '123456' to your desired password/code.

The 'reject' option is a 'safeword' to prevent the player getting stuck in the 'incorrect password' loop. Make sure they're clear on and know this safeword.. Again, you can change this to whatever.

Finally, change 'room 2' to the name of the room you want to send the player to on entering the correct code.

Davidmarks
19 Dec 2015, 00:12
That's extremely useful and very timely. I had got it working after a fashion to show a hidden exit after typing a newly invented command and was trying to remember where I had seen code which would refresh the screen and show the hidden exit . Couldn't find it anywhere when up popped your code with the ShowRoomDescription in it ! Brilliant. One further comment. Better coders than you there may be but usually the more advanced people are in a topic the less they are able to understand the difficulties of beginners and their explanations are difficult or impossible to follow. I'm sure (from what I can see) that you are in fact a good coder, Nevertheless you have just made a number of things much clearer to my now ancient brain ! For which many thanks !

OurJud
19 Dec 2015, 01:16
You're welcome :)

If you can dig anything useful out of that last post of mine, then I'm happy.

And I agree about instructions on doing something. It takes someone who knows how difficult it can be to follow an advanced tutorial, to be able to explain things clearly.

I simply explain things in the way I would like have them explained if I'd asked the question.

Davidmarks
19 Dec 2015, 10:04
One more question,.... I have never been clear as to exactly what languge the code is written in. Looks a bit C ish as I have done (a little) coding for an arduino. Trouble is, if I don't know exactly what the syntax of the language used is I am going to find it impossible !

HegemonKhan
19 Dec 2015, 10:29
from another post of mine (and also thanks to Pixie for explaining the two forms of code languages in quest):

"
Quest uses its own unique language, but it's scripting code (the NON-tag code lines~blocks) syntax is similar to C++ and~or Java, and it's main code is very similar to XML (a web~browser language like HTML ~ it's all the ' <xxx>xxx</xxx> ' or ' <xxx /> ' stuff that I like to call the 'physical creation' tag code lines~blocks), and its coding features is similar to Python (usage of Lists and Dictionaries for example), as Quest~Alex is European and Python is much more popular in Europe than in the U.S.)

I'd recommend downloading notepad++ ( https://notepad-plus-plus.org/ ), it's a good free software, you can select the programming language you want (the menu bar at the top once you got it installed and open~running), such as 'XML' for quest coding, or whatever language, for whatever else, like maybe writing JS (JavaScript) code for whatever, hehe.
"

---------------------

the "physical form, existence, manifestation, and~or instantiating of stuff~things (Elements) that is the" main code of quest is very similar to XML (a browser~web language, like HTML), which uses the "tags", as seen below:

Horizontal:

<xxx>xxx</xxx>
~ OR (for some things) ~
<xxx />

Vertical:

<xxx>
xxx
</xxx>

// -----------

<asl version="550">
// your entire mass of game code
</asl>

<game name="xxx">
// Attributes, such as:
<gameid>xxx</gameid>
<start type="script">
// scripting (action~event NON-tag code):
msg ("hi")
</start>
<attr name="turns" type="int">0</attr>
</game>

<object name="xxx">
// Attributes and~or other Objects
</object>

<function name="xxx">
// scripting (action~event NON-tag code):
msg ("hi")
</function>

<command name="xxx">
// Attributes
</command>

<turnscript name="xxx">
// Attributes
</turnscript>

<timer name="xxx">
// Attributes
</timer>

<type name="xxx">
// Attributes
</type>

// etc Elements


---------

and Scripting (action~event NON-tag code lines~blocks), some examples:

msg ("hi")

if (orc.dead) { /* scripts */ }

if (Got (potion) ) { /* scripts */ }

Set (player, "strength", 100)

game.roll = DiceRoll ("1d6")

msg ("What is your name?")
get input {
player.alias = result
}


if you can get this understood~memorized, you can do any scripting code in quest, Attribute Usage:

Object_name.Attribute_name = Value_or_Expression

<name of object>.<name of attribute> = <value or express>

AND the 'if' Script (+Attribute Usage):

if (Object_name.Attribute_name OPERATOR Value_or_Expression) { /* scripts */ }

for examples:

player.alias = "HK"
orc.dead = false
player.damage = player.katana.damage * 2
player.strength = 100

if (player.alias = "HK") { msg ("You're the most awesome person in the world! (lololol, riiiiiiight, sighs)") }

if (orc.dead) { msg ("The orc is dead") }

if (not orc.dead) { msg ("The orc is alive") }

if (student.grade > 90) { msg ("The student got an 'A' in class") }

Davidmarks
19 Dec 2015, 22:59
Thanks for that. I shall now appy a large ice pack to my ancient brain and try to figure it out ! May need the help of grandchildren !