 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Apr 09, 2005 10:59 pm Post subject: Help to write a (or several) scripts |
|
|
I would like the player to enter a password. I made text boxes with stars and I am using those scripts
#---------------------------------------------------------------------------
script, listen for code, begin
variable(key)
while (key is pressed(key:esc)==false) do,begin
for (key,2,57) do, begin # check all scancodes from "1" to SPACE
if (key is pressed (key)) then, begin
add this key(key)
end
end
check for finished codes
wait (1)
end
end
#---------------------------------------------------------------------------
#script a faire dire par un npc pour que l'on puisse rentrer le code
script, add this key, key, begin
if (key==Key:backspace) then, begin
# if backspace is pressed, reset the code
reset code
end,else,begin
# any other key is recorded
increment(nextletter)
if (show text box (346)) then,begin
L1:=key
end,else,begin
if (show text box (347)) then,begin
L2:=key
end,else,begin
if (show text box (352)) then,begin
L3:=key
end,else,begin
if (show text box (353)) then,begin
L4:=key
end,else,begin
# too many keys pressed, start again
reset code
end
end
end
end
end
show value (nextletter)
end
#---------------------------------------------------------------------------
script, check for finished codes,begin
if(L1==key:S,and,L2==key:P,and,L3==key:A,and,L4==key:M) then,begin
reset code # trigger the magical SPAM password!
show text box (333)
end
if(L1==key:Q,and,L2==key:U,and,L3==key:I,and,L4==key:T) then,begin
reset code
# end the game
game over
end
end
#---------------------------------------------------------------------------
The password is spam. But it doesn't work.
1) Could you tell me if there are errors ?
2) Could you tell me when does the scripts go? For example what is the plotscript that the npc may display ? And above all what should I do with the other scripts ?
Thanks very much in advance for the help ! |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Apr 11, 2005 6:36 am Post subject: |
|
|
The line if (show text box) doesn't do anything. show text box doesn't have a return value.
Also, key isn't changing within the script, you know. The script should look more like this:
Code: | wait for key(any key)
if key is pressed(key:S) then
(
wait for key(any key)
if key is pressed(key:P) then
(
...
|
_________________
|
|
Back to top |
|
 |
rpgspotKahn Lets see...

Joined: 16 May 2004 Posts: 720 Location: South Africa
|
Posted: Mon Apr 11, 2005 8:12 am Post subject: |
|
|
I think you should refer to the plotscript dictionary before posting these things. Check your code. Somehow It seems that you guess a lot of the code you write, hoping that it may work - Not the right way to go about it. _________________
2nd Edition out now! |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Mon Apr 11, 2005 9:22 am Post subject: Well I use the plotscript dictionary when I programm! |
|
|
This plotscripts you are reading come from Moogle1 library.
I've made change and It works a bit better by typing the letters of the password; I make change the text boxes. But there are some questions that left :
1) What could be reasons for having 0 (like countdown) in the left back corner of my screen ?
2) Could somoene give me advices with codes composed of shift+4 , shift+5 (until)7 fonts ?
Thanks very much for the advices. It has already helped me a lot! |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Mon Apr 11, 2005 4:52 pm Post subject: |
|
|
1) You have a "Show value" command right at the end of "add this key". Show value will, *insert drumroll*, show a value on the screen. You will want to comment or remove that line to avoid doing that.
2) This is going to look a bit confusing, but it's not really:
Code: |
#with the other includes:
include, scancode.hsi
#in a script somewhere
if(key is pressed(key:Left Shift)) then, begin
if(key is pressed(key:4)) then, begin
#whatever
end
if(key is pressed(key:5)) then, begin
#whatever
end
if(key is pressed(key:6)) then, begin
#whatever
end
if(key is pressed(key:7)) then, begin
#whatever
end
end
|
I hope this is what you're looking for... _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Mon Apr 11, 2005 11:51 pm Post subject: here are the new versions of my scripts but |
|
|
#---------------------------------------------------------------------------
script, listen for code, begin
variable(key)
while (key is pressed(key:esc)==false) do,begin
for (key,2,57) do, begin # check all scancodes from "1" to SPACE
if (key is pressed (key)) then, begin
add this key(key)
end
end
check for finished codes
wait (1)
end
end
#---------------------------------------------------------------------------
script, reset code, begin
show text box (371)
wait for text box
end
#---------------------------------------------------------------------------
#script displayed by an Npc so that we can enter the code
script, add this key, key, begin
suspend Npcs
suspend player
if (key==key:esc) then, begin
# if esc is pressed, reset the code
reset code
end,else,begin
# any other key is recorded
if (key==key:S)
then,begin (show text box (347))
end,else,begin
if (key==key:P)
then,begin (show text box (352))
end,else,begin
if (key==key:A)
then,begin (show text box (353))
end,else,begin
if (key==key:M)
then,begin (show text box (354))
end,else,begin
if (key==key:enter)
then,begin
(show text box (370))
then,
(proceed the HQ)) #code is ok so the plotscript begin
end, else, begin
reset code
end
end
end
end
end
resume Npcs
resume player
end
#---------------------------------------------------------------------------
script, check for finished codes, begin
if (L1==key:S,and,L2==key:P,and,L3==key:A,and,L4==key:M) then,b egin
reset code
show text box (370) # You tigger the magical password
wait for text box
end
if (L1==key:Q,and,L2==key:U,and,L3==key:I,and,L4==key:T) then,begin
reset code
#end the game
game over
end
end
#---------------------------------------------------------------------------
# script launch if we have entered the code correctly
script, proceed the HQ, begin
suspend player
suspend Npcs
# I put this here just to be sure the plotscript launch correctly
walk hero (0, south, 2)
wait for hero (0)
resume player
resume Npcs
end
#---------------------------------------------------------------------------
I still have not changed the password.
Now, here are my "few" questions :
1) Why is there now effect if I put if (key==L1) instead of if (key==key:S)? I think that I should use the global variables. They seems usefull in Moogle's script. Could somoene help me with the if statement
2) The code reset doesn't work well. If I press p directly after it has been reseted I will be ok and the two stars text box will appear
3) Npcs move whereas I have suspended them at the beginning of the plotscript.
As always, thanks in advance for the help ! |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Mon Apr 11, 2005 11:54 pm Post subject: Sorry for misspelling the 2nd question |
|
|
Here is what I mean in my 2nd question :
2) The code reset doesn't work well. If I press p directly after it has been reseted It will be ok, an the two stars text box will appear whereas it should not. |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Thu Apr 14, 2005 12:44 am Post subject: Please forgot about the previous post here are the... |
|
|
Sorry for posting a useless post again. I didn't mean that.
I've worked for 2 hours and here is the new version of my script :
I've taken the script from Moogle's website.
define script(autonumber,add this key,1,0)
define script(autonumber,check for finished codes,none)
define script (63,reset code, none)
define script (64,listen for code, none)
Global variable (4,L4,5,L5,6,L6,7,L7)
Global variable (8,nextletter)
Global variable (9,L9)
#---------------------------------------------------------------------------
script, reset code, begin
show text box (371)# you have entered the wrong password
wait for text box
nextletter:=0
L4:=0
L5:=0
L6:=0
L7:=0
L9:=0
end
#---------------------------------------------------------------------------
script, listen for code, begin
variable(key)
while (key is pressed(key:esc)==false) do,begin
for (key,2,57) do, begin # check all scancodes from "1" to SPACE
if (key is pressed (key:backspace)) then, begin
add this key(key)
end
end
check for finished codes
wait (1)
end
end
#---------------------------------------------------------------------------
script, add this key, key, begin
suspend Npcs
suspend player
if (key==key:esc) then, begin
# if escape is pressed, reset the code
reset code
end,else,begin
# any other key is recorded
increment (nextletter)
if (nextletter==4) then,begin
L4:=key
then, (show text box (347))
end,else,begin
if (nextletter==5) then,begin
L5:=key
then, (show text box (352))
end,else,begin
if (nextletter==6) then,begin
L6:=key
then, (show text box (353))
end,else,begin
if (nextletter==7) then,begin
L7:=key
then, (show text box (354))
end,else,begin
if (nextletter==9) then,begin
L9:=key
(show text box (354))#repéter la text box a 4 étoiles.
end, else, begin
reset code
end
end
end
end
show value (nextletter)
end
end
resume Npcs
resume player
end
#---------------------------------------------------------------------------
script, check for finished codes, begin
if (L4==key:S,and,L5==key:P,and,L6==key:A,and,L7==key:M,and,L9==key:enter) then, begin
reset code
show text box (370)
then ,
then,
(proceed to the HQ)# You have managed to enter the password! Proceed to the Hq!
wait for text box
end
if(L4==key:Q,and,L5==key:U,and,L6==key:I,and,L7==key:T,and,L9==key:enter) then, begin
reset code
game over #end the game
end
end
#---------------------------------------------------------------------------
Here are my questions :
1) What does 0 refers to in the reset code plotscript ?
2) What does the "increment letter" command requires to work ?
3) Do I have to use global variables 1,2,3 and 4 like in Moogle script ?
4) What is exactly the meaning of the command L9:=key ?
Thanks in advance for the help ! |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Thu Apr 14, 2005 3:07 am Post subject: |
|
|
1) Er, the 0 mean... 0... which I guess means "no key"
2) There is no such official command, and I see no script definition for it in your script. I also don't see anywhere where it's used...
3) You don't need to. You could use globals 1, 68, 294 and 3 if you wanted.
4) that line sets L9 to whatever number is in key, which is a parameter passed to the "add this key" script. _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Thu Apr 14, 2005 4:26 am Post subject: |
|
|
Okay, that script now looks like it should work. But I didn't write it (the original author is credited on the site) and take no responsibility for it.
All you have to do for the script to work, I think, is to put it in an "on keypress" script in one of your maps. However, you're skipping letters 1, 2, 3, and 8 -- also, you are not checking if the correct keys are read. Fixing this should make things go how you want them to. _________________
|
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Thu Apr 14, 2005 10:19 pm Post subject: Using the increment letter command |
|
|
I would like to define a sub script so that the "increment letter" command work correctly ? Could somoene help me to do that ?
Thanks in advance! |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Thu Apr 21, 2005 7:03 am Post subject: So could somoene help me ? |
|
|
So could somoene help me to write the "increment letter" lines ?
Thanks in advance ! |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Thu Apr 21, 2005 7:26 am Post subject: |
|
|
I didn't go through reading your entire code, but I used the 'edit - find' tool on my window, and found that there exists no command in your script (copied from Moogle1's site) that is called 'increment letter'. I found the command:
increment(nextletter)
In this line, nextletter is the name of a variable. This command is taking the variable nextletter and incrementing it by one (that is, adding one to its value and then storing this in its place). If that is not clear, it is the same thing as typing:
nextletter:=(nextletter+1)
Now I am not sure what you are asking for. What do you want to happen, and how is it not happening? |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Fri Apr 22, 2005 7:24 am Post subject: |
|
|
Okay, I read through the script a bit more carefully, and I think I have found what might be the errors at the bottom of your concern over "increment letter":
1. In the 'reset code' script, the global variable 'nextletter' has been set to zero. However, in the 'add this key' script, the only time a key will register is when 'nextletter' is either 4 or above. Thus, the first 3 times you press a key, nothing will happen.
Solution:
Either set 'nextletter' to start at 3 (since it is incremented BEFORE the 'if' checks) in the 'reset code' script, or start your 'if' checks in the 'add this key' script with 'if(nextletter==1),then' for the variable 'L4'.
2. Right now, it seems that every time a key is pressed other than esc, 'nextletter' will be incremented by one. BUT after the fourth letter (L7) the variable 'nextletter' will have been incremented to 8, and so will trigger none of the 'if' checks in the 'add this key' script.
Solution:
Change the final 'if' check in 'add this key' to:
if(nextletter==8),then
It would make sense then to call this letter 'L8', rather than 'L9'. Note that it is NOT necessary to change the global variable declaration at the top of your script for this to work. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Apr 22, 2005 6:45 pm Post subject: |
|
|
I dug up my old answer to this question. Did you see my answer? Prehaps it would be easier to work on fixing this version, if it doesn't work.
Code: |
#---------------------------------------------------------------------------
script, reset code, begin
nextletter:=1
L1:=0
L2:=0
L3:=0
L4:=0
showtextbox() #"please enter code :"
end
#---------------------------------------------------------------------------
script, listen for code, begin
variable(key)
reset code
# check all scancodes from "1" to SPACE
while (key is pressed(key:esc)==false) do, begin
for (key,2,57) do, begin
if (key is pressed(key)) then,begin
add this key(key)
end
end
check for finished codes
wait(1)
end
end
#---------------------------------------------------------------------------
script, add this key, key, begin
#script liee text box computer
if (key==Key:Backspace) then, begin
# if backspace is pressed, reset the code
reset code
end,else,begin
# any other key is recorded
increment(nextletter)
if (nextletter==2) then,begin
L1:=key
showtextbox() #"please enter code : *"
end
if (nextletter==3) then,begin
L2:=key
showtextbox() #"please enter code : **"
end
if (nextletter==4) then,begin
L3:=key
showtextbox() #"please enter code : ***"
end
if (nextletter==5) then,begin
L4:=key
showtextbox() #"please enter code : ****"
wait (4) #slight pause, so that the player can see 4 stars. remove if you want.
end
end
end
#---------------------------------------------------------------------------
script, check for finished codes,begin
if(L1==key:S,and,L2==key:P,and,L3==key:A,and,L4==key:M) then,begin
reset code # trigger the magical SPAM password!
show text box (333)
wait for textbox
reset code
end
if(L1==key:Q,and,L2==key:U,and,L3==key:I,and,L4==key:T) then,begin
# end the game
game over
end
if (nextletter>=5) then,begin
# too many keys pressed, start again
reset code
end
end
#----------------------------------------------------------- |
I've had enough of dealing with problems from this script though  _________________ "It is so great it is insanely great." |
|
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
|