Jump to content

Giving Keys With Buttons And Making A Choice


Rendril

Recommended Posts

Presents player with two choices, picking one blocks them from accessing the other.
There are many ways to do this, I used a single form with 2 input buttons.
Could be made with a template and loops for some nice multi-tiered quests.

Content:
[code]
<!-- content separator -->
Two paths lie before you, going down one means you cannot retrace your steps and go down the other.
<br />Which path will you take?
<form method="post" action=""><br /><br />
<input type="submit" name="left" value="Go Left"/>
<input type="submit" name="right" value="Go Right"/>
</form>
<!-- content separator -->
You walk down the left path. A boulder crashes into the road from a cliff and lands behind you, blocking the way home.
<!-- content separator -->
Walking over the bridge on the right, you feel it crumbling under you and dash to the other side. The bridge is broken and you move on.
<!-- content separator -->
The way back is blocked.
[/code]

Code:
[code]
@vz = "rendrilrevant";//the prefix to use for keys
//check whether users holds either of the keys
if(mds_has_rpcq_keys(@vz . "left-key") || mds_has_rpcq_keys(@vz . "right-key")){
echo @content[4];
}
else{
//if a buttron is set, give relevant key and display details
if(isset(@input['left'])){
mds_give_rpcq_keys(@vz . "left-key");
echo @content[2];
}
else if(isset(@input['right'])){
mds_give_rpcq_keys(@vz . "right-key");
echo @content[3];
}
else{
echo @content[1];
}
}
[/code]

Link to comment
Share on other sites

[quote name='Rendril' date='28 October 2009 - 07:15 PM' timestamp='1256775331' post='46017']
Presents player with two choices, picking one blocks them from accessing the other.
There are many ways to do this, I used a single form with 2 input buttons.
Could be made with a template and loops for some nice multi-tiered quests.

Content:
[code]
<!-- content separator -->
Two paths lie before you, going down one means you cannot retrace your steps and go down the other.
<br />Which path will you take?
<form method="post" action=""><br /><br />
<input type="submit" name="left" value="Go Left"/>
<input type="submit" name="right" value="Go Right"/>
</form>
<!-- content separator -->
You walk down the left path. A boulder crashes into the road from a cliff and lands behind you, blocking the way home.
<!-- content separator -->
Walking over the bridge on the right, you feel it crumbling under you and dash to the other side. The bridge is broken and you move on.
<!-- content separator -->
The way back is blocked.
[/code]

Code:
[code]
@vz = "rendrilrevant";//the prefix to use for keys
//check whether users holds either of the keys
if(mds_has_rpcq_keys(@vz . "left-key") || mds_has_rpcq_keys(@vz . "right-key")){
echo @content[4];
}
else{
//if a buttron is set, give relevant key and display details
if(isset(@input['left'])){
mds_give_rpcq_keys(@vz . "left-key");
echo @content[2];
}
else if(isset(@input['right'])){
mds_give_rpcq_keys(@vz . "right-key");
echo @content[3];
}
else{
echo @content[1];
}
}
[/code]
[/quote]

this could be used to make an adventure of epic proportions :) time to get to work :D

Link to comment
Share on other sites

[quote name='I am Bored' date='29 October 2009 - 07:36 PM' timestamp='1256844982' post='46089']
this could be used to make an adventure of epic proportions :P time to get to work :D
[/quote]

Using a form to set a button is great, but what I could really use is a form text box which can have the contents stored to an MD variable.

The other question I have is when the example above is set, the MD script doesn't wait for the user to click a button, is submitting the form after clicking a button causing the MD script to refresh and run again with the button now set?

Being able to have text input from a user would make just about anything possible.

Cutler

Link to comment
Share on other sites

Form text box can easily be done, you can use anything HTML has.
I'll post an example using both <textarea> , <select> and maybe radio/checkbox.

The thing to be careful of when accepting user-typed input is that it is safe for consumption, don't assume the user sent it correctly. Another note, allow a certain level of tolerance for the input, not all will make it the exact format you want and speaking from my own experience, I make typos on a constant basis.

Once the button is pressed and the script loads again, it will have done so with the key in the user's possesion.


For a simple text input try using just that
[code]
<input type="text" name="answer" />
[/code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...