 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 3:44 pm Post subject: I need a code for a box that's lets you type in a password |
|
|
I'm doing a version of Animal Crossing (Yes, the Gamecube/Nintendo DS game) on the OHRRPGCE. My problem is, in the game, K.K. Slider will play a song for you if you request it by typing in a box that comes up when you talk to him, and you can enter cheat codes by talking to Tom Nook in a similar way.
I either need a code that can make a box that you can enter a code into, then it checks if it matches something else (it will need to return true or false so I can continue the code) OR I need a code that checks if a hero's name matches something else and still return true/false.
The hero name checker would probably be simpler, and I already use heroes for changeable things in the game (NPC catchphrases, the town name, the island name, etc.) because I only need two usable heroes. Is this at all possible? |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 3:48 pm Post subject: |
|
|
That sounds like it listens for passwords on the map. I need an actual box to pop up to type things in. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 3:55 pm Post subject: |
|
|
Ok... Can you tell me what that means? I'm not a programmer, so I don't understand how strings work. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 4:10 pm Post subject: |
|
|
That page still doesn't explain how to have the player type in a box and check it against different passwords. Look, I gave the way that would I prefer in the first post, and that is to check if a hero name is the same as something else. I either need a code that I can edit and it says what each thing means in plain English, or I need an explanation in plain English. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Sat Jan 19, 2008 4:19 pm Post subject: |
|
|
So you want me to do all of the work for you?
There's a nice big plotscripting dictionary and tutorial over at the wiki. Why don't you learn how to plotscript before trying to do something as ambitious as an OHR remake of Animal Crossing? _________________ Calehay |
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 4:23 pm Post subject: |
|
|
Notice how I'm not asking for help on ANYTHING else? That's because I figured out how to make an OHR version with very little modifications. I'm only 13, so the fact that I'd be able to code the rest of that is surprising, seeing as how most people I know wouldn't understand any of it. The only part I don't understand is strings. One tiny part. Sorry I asked for help. I guess I'll have to make yet another modification making it even less like the original games. Sorry for me being ignorant. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Sat Jan 19, 2008 4:40 pm Post subject: |
|
|
Quote: | Notice how I'm not asking for help on ANYTHING else? |
Notice how it's your first post?
Quote: | The only part I don't understand is strings. |
So, why didn't you look it up in the plotscripting dictionary?
The wiki is quite clear.
You will need these commands to do your script:
Code: | stringcompare - compares two strings
(syntax) $#="[i]yourtexthere[/i] (ex. $1="happy") - allows the plotscripting to set a string's values. You can also use $#+ to add to the end of a string.
inputstring - allows a player to input a string
if - then - performs a set of commands if the requirements are met.
variable([i]yourtexthere[/i]) (ex. variable(happy)) - allows you to create a variable. |
Players input a string. You then make strings for all your commands. You then compare one of the strings, making the true or false value go to a variable. You then do an if-then statement to find out if the string and the inputted string match, and tell it to perform what you want it to perform. Repeat that check for each of your strings against the inputted string. _________________ Calehay |
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sat Jan 19, 2008 4:44 pm Post subject: |
|
|
That made a little more sense. I'll go and test that to see if I understood correctly. Sorry for being rude.
EDIT: Well, it worked... Almost. I used Hello World as an example script (because it seems everyone uses that) but only the "e" from Hello and the "W" from World showed up (just as white letters under the player) but when I pressed enter after typing everything, it showed the text box I wanted. Here's my code:
Code: |
include, plotscr.hsd
include, npc_tag.hsi
#Yes, I used the npcs and tags tutorial to test with.
plotscript, Hello World String, begin
input string (2, true)
$1="Hello World"
stringcompare (2, 1)
then
show text box (7)
end
end |
EDIT again: After testing this again, I found that pressing Enter at any time after talking the NPC I gave this code to showed text box 7. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Sat Jan 19, 2008 6:43 pm Post subject: |
|
|
This would let the text box to show up if anything is placed in the box. It should be more like this:
Code: |
Plotscript, Hello World String, begin
Variable (stringstatus)
input string (2)
$1="Hello World"
string status := stringcompare (2, 1)
If (stringstatus == -1) then #I had problems using the True constant, but I don't know why
(
#Do what you want here.
)
#And repeat this for the rest of your "Hello Worlds"
end
|
Stringcompare will give out a value, much like putting 1 + 1 would result in two. But unless you capture that into a variable, it won't work.
You could also do
Code: |
If (stringcompare (2, 1) == true) then
(
#do stuff
)
|
and get rid of the variable, but I tend to put that type of stuff in variables since it helps me understand what is going on. I'm not a very efficient programmer.
I tried this but I found that you could only put in certain letters. I'm not really sure why that's happening, but I'm going to see if I can try it out on an earlier version of the OHR to make sure it's not a bug. I might be doing something incorrectly, but I have no idea what.
The work around to that is very messy, but would look something like this:
Code: |
plotscript, Hello World Script, begin
suspend player
Variable (inputkey)
Variable (stringstatus)
Variable (aredone)
Variable (cutme)
While (aredone == false) do
(
wait
If (keyispressed(#scancode, * for more info) then
(
$2+"#whateverletter"
show string at (2, 160, 100)
)
#repeat for every key that can be pressed.
If (keyispressed(28) then #that's the enter key
(
aredone := true
)
If (keyispressed(14) then #backspace key
(
cutme := stringlength (2)
deletechar (2, cutme)
#deletes the last character, just like the backspace key.)
)
#Do the checking stuff just like before.
end |
*the scancode you have to input corresponds to these http://gilgamesh.hamsterrepublic.com/wiki/ohrrpgce/index.php Plot:Key_is_pressed. You input the number for the key you want pressed.
Problem with this one is that it only allows one case, and can be a little touchy. (You basically have to tap the keys to make sure that you don't put in more than one of a letter. You might be able to help this by upping the wait value.) _________________ Calehay |
|
Back to top |
|
 |
rarehunter41
Joined: 19 Jan 2008 Posts: 8
|
Posted: Sun Jan 20, 2008 7:07 am Post subject: |
|
|
Thank you. That helped a lot.
EDIT: All my code does is freeze my game, it doesn't even show the text as I'm typing it. My code is:
Code: | plotscript, Hello World Script, begin
suspend player
Variable (aredone)
Variable (cutme)
While (aredone == false) do
(
wait (2)
If (keyispressed(16)) then
(
$1+"Q"
show string at (2, 160, 100)
)
If (keyispressed(17)) then
(
$1+"W"
show string at (2, 160, 100)
)
If (keyispressed(18)) then
(
$1+"E"
show string at (2, 160, 100)
)
If (keyispressed(19)) then
(
$1+"R"
show string at (2, 160, 100)
)
If (keyispressed(20)) then
(
$1+"T"
show string at (2, 160, 100)
)
If (keyispressed(21)) then
(
$1+"Y"
show string at (2, 160, 100)
)
If (keyispressed(22)) then
(
$1+"U"
show string at (2, 160, 100)
)
If (keyispressed(23)) then
(
$1+"I"
show string at (2, 160, 100)
)
If (keyispressed(24)) then
(
$1+"O"
show string at (2, 160, 100)
)
If (keyispressed(25)) then
(
$1+"P"
show string at (2, 160, 100)
)
If (keyispressed(30)) then
(
$1+"A"
show string at (2, 160, 100)
)
If (keyispressed(31)) then
(
$1+"S"
show string at (2, 160, 100)
)
If (keyispressed(32)) then
(
$1+"D"
show string at (2, 160, 100)
)
If (keyispressed(33)) then
(
$1+"F"
show string at (2, 160, 100)
)
If (keyispressed(34)) then
(
$1+"G"
show string at (2, 160, 100)
)
If (keyispressed(35)) then
(
$1+"H"
show string at (2, 160, 100)
)
If (keyispressed(36)) then
(
$1+"J"
show string at (2, 160, 100)
)
If (keyispressed(37)) then
(
$1+"K"
show string at (2, 160, 100)
)
If (keyispressed(38)) then
(
$1+"L"
show string at (2, 160, 100)
)
If (keyispressed(40)) then
(
$1+"'"
show string at (2, 160, 100)
)
If (keyispressed(44)) then
(
$1+"Z"
show string at (2, 160, 100)
)
If (keyispressed(45)) then
(
$1+"X"
show string at (2, 160, 100)
)
If (keyispressed(46)) then
(
$1+"C"
show string at (2, 160, 100)
)
If (keyispressed(47)) then
(
$1+"V"
show string at (2, 160, 100)
)
If (keyispressed(48)) then
(
$1+"B"
show string at (2, 160, 100)
)
If (keyispressed(49)) then
(
$1+"N"
show string at (2, 160, 100)
)
If (keyispressed(50)) then
(
$1+"M"
show string at (2, 160, 100)
)
If (keyispressed(52)) then
(
$1+"."
show string at (2, 160, 100)
)
If (keyispressed(57)) then
(
$1+" "
show string at (2, 160, 100)
)
If (keyispressed(28)) then #that's the enter key
(
aredone := true
)
If (keyispressed(14)) then #backspace key
(
cutme := stringlength (2)
deletechar (2, cutme)
#deletes the last character, just like the backspace key.)
)
)
$2="HELLO WORLD"
While (aredone == true) do
(If (stringcompare (2, 1) == true) then
(
show text box (7)
resume player
)
else
(
resume player
)
)
end |
EDIT: I just tried making my own script, and as far as I can tell it should be working, but the stringcompare keeps coming up false. I split the script into two parts because I overlooked a small detail and I thought that being in the same script was the problem, but I fixed that now. Here's what I have.
Code: | plotscript, Rename Type Here, begin
if (find hero (hero:Type Here) ==-1)
#If the hero isn't in the party, it needed to be added
then, begin
add hero (hero:Type Here)
#Add the hero...
swap out hero (hero:Type Here)
lock hero (hero:Type Here)
#Then swap out and lock it so the player can't see it.
rename hero(hero:Type Here)
#Then a box comes up saying Hello World at the top (by editing Global Text Strings) and inside of it saying Type Here.
show text box (9)
#A text box saying "Let's see what you wrote" and I attached the next plotscript to it.
end
else, begin
#If the hero is already in the party (meaning you've already talked with the NPC) it doesn't need to be added again...
rename hero(hero:Type Here)
#Just renamed.
show text box (9)
end
end
plotscript, Hello World Script, begin
#Attached to text box 9
get hero name (1, 2)
#Get Type Here's new name and put it in string 1
$2="Hello World"
#What should have been typed
If (stringcompare (2, 1))
#Are they the same?
then, begin
show text box (7)
#The NPC says "Congratulations!"
end
else, begin
show text box (8)
#The NPC says "That isn't Hello World!"
end
end |
And no matter how much I edit, it always says "That isn't Hello World!" What am I doing wrong? |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Jan 20, 2008 9:33 am Post subject: |
|
|
Hey, the OHR be meant to be a simple engine to learn and use, and trying to force every user to learn all of plotscripting, like everyone often does, just for the sake of such a simple script seems to silly to me.
Yes, inputstring was broken, thanks for pointing it out, it will be fixed for the Voxhumana release (probably today or tomorrow).
Calehay wrote: | Code: | string status := stringcompare (2, 1)
If (stringstatus == -1) then #I had problems using the True constant, but I don't know why
(
#Do what you want here.
)
|
|
Don't do this. Firstly, there's totally no need to put the result of strigncompare in a variable, secondly, try to never write "==true" or "==1" or "==-1". Any non-zero value counts as true. In fact, stringcompare does return -1, which is not equal to the true constant, which is 1. We can't change it now, because some people seem to be checking for -1. Bah, we never win. You should just write
Code: | if (string compare (2, 1)) then ( .... ) |
And wow, it's really crazy that still nobody knows about or uses the constants for the scancodes. Include 'scancode.hsi' and use "key:Q" instead of "16", etc. Of course, you don't need them for this.
Your script was broken because you were adding letters to string 1, but displaying string 2. It froze because of the second while loop you added. Now, after the first while loop, the player has entered the password, and aredone is always true. There's no need to check it, and no need to loop. It freezes because stringcompare returns -1, not 1, as mentioned above.
Also, waiting more than one tick when polling the keyboard leads to missed keypresses. To avoid "touchyness", use 'plot:keyval' instead: write "keyval(key:whatever) >> 1" instead of "keyispressed(key:whatever)". Doing that means you get the key repeat behaviour you're used to when typing.
So here are the two scripts, pick one.
With input string:
Code: | plotscript, Hello World Script, begin
input string (1)
$2="Hello World"
if (stringcompare (1, 2)) then (
show text box (7)
exit script
)
$2="Cheat code"
if (stringcompare (1, 2)) then (
#etc
exit script
)
# if we got to this point, no valid message was typed in
# show a textbox
end |
You might also like to put a textbox in the middle of the screen behind it, either blank or with instructions:
Code: | show textbox (something)
input string (1, 38) #limit length to just shorter than the screen
advance textbox #esc doesn't advance textboxes |
You can also do something special if the player cancels the input.
With renaming heroes:
I'm not sure exactly how you were using renameable heroes to name things, but I guess you could do something like this:
Code: | plotscript, Hello World Script, begin
add hero (hero:renameable thing) # assume the hero has "rename when added to party" set, otherwise use "rename hero"
get hero name (1, find hero (hero:renamable thing))
delete hero (hero:renamable thing)
$2="Hello World"
#etc
end |
_________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Sun Jan 20, 2008 11:18 am Post subject: |
|
|
The Mad Cacti wrote: | Hey, the OHR be meant to be a simple engine to learn and use, and trying to force every user to learn all of plotscripting, like everyone often does, just for the sake of such a simple script seems to silly to me. |
This is akin to someone claiming they're going to go to Jupiter, then asking how the telescope works. I find it foolish for someone claiming to make an extremely advanced plotscripting project to not know even the general basics. _________________ Calehay |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|