 |
Castle Paradox
|
| View previous topic :: View next topic |
| Author |
Message |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Fri Mar 23, 2007 5:18 am Post subject: |
|
|
| I understand why Pause has a toggle on it, but what's the deal with the toggle on TalkwithD? Why do you need the whole "disactive" thing? |
|
| Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Fri Mar 23, 2007 6:25 am Post subject: |
|
|
Yeah, not sure what you're trying to accomplish with the disactive variable either. It looks to me that right now the player will get the special text box the first time they press d, but since that toggles disactive on, the second time they press d the game will simply pause for 2 ticks and flip disactive back off. I'm guessing this isn't the behavior you intended.
It seems to me that your script is complicated with a lot of unneccessary things. Unless you're doing something with disactive that I don't know about, I'd ditch it completely, so in your mykeypressed script you can simply have:
| Code: | if (key is pressed(key: d)) then, begin
talkwithD
end |
and you can ditch the undoD script altogether. This might solve the problem (if this is the problem you're having) of pressing d working only every other time.
Further, just as an FYI, you have some stuff in there that does absolutely nothing. For example, the while loop in the undoD script. What you have:
| Code: | script, undoD, begin
while (disactive) do, begin
disactive:=false
wait (2)
end #end for the while
end #end of the script |
will do exactly the same thing as:
| Code: | script, undoD, begin
disactive := false
wait (2)
end |
Since the check on the while loop is always set to false after one iteration. Simply running the code will execute it as many times as sticking it in the while loop no matter what, unless the check skips the loop entirely. However, the fact that the while loop only activates when disactive is false doesn't matter, since you're only setting disactive to false anyway. In other words, setting a false disactive to false is functionally identitcal to skipping the command that sets a false disactive to false. Does that make sense?
You have the same kind of extraneous while loop in your mykeyispressed script. It will behave the same if you ditch the while(loopkey) loop.
Also, not sure why you want Xcheck, Ycheck, and mydirect to be global variables. They seem to be only used in the talkwithD script. Are they used elsewhere, and for what purpose? If not, you would probably be better off making them local variables.
Couple of questions:
What is the pause functionality supposed to do? You didn't post the pause scripts, I'm wonding if they might be causing problems (which seems possible since you're using a bunch of global variables.)
What exactly isn't working about these scripts? Error messages? Does it compile properly but seemingly does nothing in the game? Does it work occasionally? If you can describe the behavior you're getting precisely, we will be much better equipped to figure out the problems in the script. |
|
| Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Mar 24, 2007 11:58 pm Post subject: Some explanations |
|
|
Ok some answers and explanations:
Camdog said
| Quote: |
I'm not sure what you're trying to accomplish with the disactive variable either. |
The disactive variable is supposed to prevent the script from overloading as the player quickly presses on D several times because nothing appears on screen. It is for the same reason that I put an loop key variable in the keypress script but I'm not just that it is useful
Camdog also said
| Quote: | | Xcheck, Ycheck, and mydirect to be global variables |
As I want to check X and Y position of npcs all along the game on different maps global variables may be useful... or should I use simple variable instead?
And then Cambog add
| Quote: | | What is the pause functionality supposed to do? |
The pause functionality allows the player to stop playing outside
battle. The pause and unpaused store the time datas when numlock is pressed and restore it when the player presses numlock again.
What do you think of using a while loop and the map autorun script to launch talkwithD? Do you find this useful?
Anyway thanks for answering so quickly! Any advice is welcomed! _________________ It's time to make games! |
|
| Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Sun Mar 25, 2007 3:46 am Post subject: |
|
|
Use on different maps doesn't matter in variables. The difference between global variables and local variables is that you can use globals through different scripts, while locals are made and unmade within one script. Local variables should be fine here.
And to prevent a key-press script from recursion, instead of making it a toggle, just put a "wait (1)" at the bottom.
And you totally don't need a while loop. The script I posted on the last page should work just as it is.
And I'm guessing "pause script" must be another script you've got somewhere? And that it probably only works outside of cutscenes? |
|
| Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sun Mar 25, 2007 11:20 am Post subject: |
|
|
You almost certainly do NOT want to use a map autorun script to call these scripts. "Mykeypressed" should be called as an on-keypress script only. Also, as it is posted right now, this script should not compile, as "Mykepressed" is missing an end command at the very end of the script to terminate the script as a whole.
I'm really not seeing anything else wrong here, though. Can you tell us what happens incorrectly when you try to use this script (what happens when you press 'D', or any other key, in the game)? _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
| Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sun Mar 25, 2007 9:04 pm Post subject: some more information |
|
|
uncommon said
| Quote: | | the pause script probably only works outside of cutscenes |
Yes it doesn't not work while cutscene and but it works outside battles. Tell me if you want to use it in your game.
msw188 said
| Quote: | | You certainly do NOT want to use a map autorun script to call these scripts | Ok! As the mapautorun script is not what I need, I won't use it then.
msw188 also said
| Quote: | | Can you tell us what happens incorrectly when you try to use this script (what happens when you press 'D', or any other key, in the game)? | Well the problem is that when I press D nothing happens. No text box appears and the npc does not face the hero either.
That's all! Good luck on making your game! _________________ It's time to make games! |
|
| Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sun Mar 25, 2007 9:38 pm Post subject: |
|
|
Hmm, I'm not sure what the problem could be. Is your pausing script working when you hit numlock? Here's another thing to try. Put in the command
at the top of your TalkWithD script. Then when you press D in a game, a number zero should appear in the bottom right corner. If it appears, then the script is getting called correctly and there is something wrong with that script. If the zero does not appear, then the script is not even being called and there is some kind of problem with the MyKeyPressed script. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
| Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Tue Mar 27, 2007 5:41 am Post subject: |
|
|
Great news! I've put
at the top of my script and when I press D 0 appears! The script is called correctly. Then we can deduce that the text boxes does not appear because the npc is not detected at spot. I really wonder why...
Anyway what about replacing the global variables by simple variable?
| Code: |
script, talkwithD, begin
show value (0) #allows to make tests
suspend player
suspend npcs
#set variable (MyDirect, herodirection(me)) # old global variables
#x check := hero x
#y check := hero y
variable (j, ???)
variable (k, ???)
for (j,k) do begin
?
end #end of variable
switch (hero direction (me)) do, begin
case (north) do (y check -= 1)
case (south) do (y check += 1)
case (left) do (x check -= 1)
case (right) do (x check += 1)
end
switch (NPC at spot (Xcheck, Ycheck)) do, begin
case(2) do , begin
#stuff for npc 2
set npc direction (2,(MyDirect+2,mod,4))
# facing player simulated through plotscripting
show text box (78)
wait for text box
end
case(9) do, begin
#stuff for npc 2
set npc direction (9, (MyDirect+2,mod,4))
show text box (61)
wait for text box
end
end #end of the switch
resume player
resume npcs
end #end of the plotscript
|
As always thanks very much for the help! _________________ It's time to make games!
Last edited by bis_senchi on Sat Mar 31, 2007 1:18 am; edited 1 time in total |
|
| Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Tue Mar 27, 2007 6:15 am Post subject: |
|
|
Did you post the script exactly as it appears in your .hss file? Does it compile like that? The following:
| Code: | variable (j, ???)
variable (k, ???)
for (j,k) do begin |
Looks like it will throw up errors, as variable only takes one argument and shouldn't understand ???, and the format of a for loop is:
| Code: | | for(counter,start,finish,step) do(commands) |
If this isn't what you've compiled, please post exactly what you've compiled. If it is, I'm shocked it compiled and perhaps one of the developers could explain why the above doesn't throw up errors? |
|
| Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Thu Mar 29, 2007 3:34 am Post subject: |
|
|
Oh, that's easy, Camdog. It's because you can define more than one variable in the command. You (and prolly bis_senchi also) are probably confusing the second argument as setting the variables value, while really it's just making another variable called "???". Though I would expect the compiler to complain about defining an unused variable, it would've gone through without a hitch.
Though, really, you could just write it
But really, Bis, what was the intended use for j and k? You've got them in a for loop that isn't doing anything, and doesn't really even need to be there. The variables we were telling you should be local instead of global were "MyDirect" "x check" and "y check". You don't have do do anything differently with the script, except add in a line at the top what says
| Code: | | variable (MyDirect, x check, y check) | and get rid of the globals you had with those names. |
|
| Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Thu Mar 29, 2007 7:03 am Post subject: |
|
|
PROBLEM SOLVED! At least I'm pretty sure. I figured this out two days ago, but CP went down pretty much as I was trying to post it. Luckily I had copied the text in case I was logged out (having already lost a lot of text when I tried to look at the plotscript dictionary and it took my window), and I will paste it below.
SHOOT!!! BLAST! I just had a really long post explaining some problems, and then I realized what the real problem is and I had to look at the Plotscript dictionary, and when I tried to open it it took the place of this screen. Okay, here we go.
First of all, the type of variable you are using should have no effect at all. I'd keep the globals and get rid of the new j and k local variables.
Second and most importantly, we've been had by NPC at Spot, which returns a reference to the NPC and not its ID number. Its an easy fix, just replace the line:
| Code: | | switch(NPC at spot (Xcheck, Ycheck)) |
with
| Code: | | switch(get NPC ID (NPC at spot (Xcheck, Ycheck)) ) |
That's the main thing. However, there is another problem with the flow. Right now, holding down the D key would do something like this:
1. Call TalkWithD
2. Call UndoD (which does NOT cancel TalkWithD, just interrupts it)
3. Call TalkWithD again
4. Call UndoD again
...
To fix this, move the line:
to the TOP of your TalkWithD script, and add the line:
to the bottom of your TalkWithD script. Then you will have to make a slight rewrite of your MyKeyPressed script like so:
| Code: | script, MyKeyPressed, begin
if(disactive==false),then
begin
#everything that you have right now,
#except take out the if(disactive==false)
#check for calling TalkWithD, and
#get rid of UndoD altogether
end #end of if
end #end of script |
Do you understand all of this? Please try this and let us know if it worked. I'm pretty sure that this should solve all of the problems (its funny, in my last post I was about to try and blame The Mad Cacti's new switch command, when in fact it was my own dumbness involving NPC at Spot) _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
| Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Mar 31, 2007 1:15 am Post subject: We're getting very close to what we need! |
|
|
Hello guys! Ok! Great news! We're getting very close to what I need!
The command
| Code: | | switch(get NPC ID (NPC at spot (Xcheck, Ycheck)) ) |
fits perfectly the situation: the text boxes appears! The one thing that left is: how to make it disappear using D and D only!
Here are the new bunches of scripts!
| Code: |
define script (21, mykeypressed,none) #extra keys pause and D
define script (23, mykeypresswhilespeaking, none) #special keypress script: you can't use the space bar
define script (autonumber, talkwithD,none)
#-------
Global variable (6, loopkey)
#---------------------------------------------------------------------
script, mykeypressed, begin
loopkey:=true #prevents keypress from overloading
while (loopkey) do, begin
if (key is pressed(key: numlock)) then, begin
if (pauseisactive==false) then, begin
pause script
end, else, begin
#thus, pauseisactive must be true
unpaused script
end #end of the first if
end #end of the second if
#numlock is pressed for pause
if (key is pressed(key: d)) then, begin
talkwithD
end
loopkey:=false
wait (1) #wait 1 is very very important
end #end of the while loop
end #end of the plotscript
#---------------------------------------------------------------------
script, talkwithD, begin
suspend player
suspend npcs
set on keypress script (23)
#from now on you can't use the space bar
variable (MyDirection, Xcheck, Ycheck)
MyDirection:= hero direction (me)
Xcheck:= heroX (me)
Ycheck:= heroY (me)
switch (hero direction (me)) do, begin
case (north) do ( Ycheck -= 1)
case (south) do ( Ycheck += 1)
case (left) do ( Xcheck -= 1)
case (right) do ( Xcheck += 1)
end
switch (get NPC ID (NPC at spot (Xcheck, Ycheck)) ) do, begin
case(2) do , begin
set npc direction (2,(MyDirection+2,mod,4))
show text box (61)
wait for key (key:d)
wait for text box
set on keypress script (21)
end
case(9) do, begin
set npc direction (9, (MyDirection+2,mod,4))
show text box (78)
wait for key (key:d)
wait for text box
set on keypress script (21)
end
end #end of the switch
resume player #if nothing happens then...
resume npcs
set on keypress script (21)
end #end of the plotscript
#---------------------------------------------------------------------
script, mykeypresswhilespeaking, begin
if (key is pressed (key:space)) then, begin
suspend player
wait(1)
resume player
end
if (key is pressed (key:d)) then, begin
wait for text box
set on keypress script( 21)
end
end #end of the script
#---------------------------------------------------------------------
|
As you read those scripts, it still doesn't work correctly: I will have to make the text boxes disappear using the space bar. It is as if the set on keypress command didn't work!
Thanks very much for both help and interest! _________________ It's time to make games! |
|
| Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sat Mar 31, 2007 5:28 am Post subject: |
|
|
Is it that important that the player must read through these text boxes using D as well? This will be very difficult (in fact, offhand I think it may be impossible), UNLESS you can be sure beforehand that the text that is activated by D is never longer than only one box. If you can be sure of this, then your new script is the right idea, it just needs changed.
First, insert the line
| Code: | | suspend box advance |
at the top of TalkWithD, as this command is what turns off the space bar from working. Put
at the bottom of TalkWithD to turn it back on when we are done. Take out all of your code:
| Code: | wait for key (key:d)
set on keypress script (21) |
in the cases in your TalkWithD script, leaving the wait for textbox command in. Then rewrite your new MyKeypressWhileSpeaking script like so:
| Code: | script, mykeypresswhilespeaking, begin
if (key is pressed (key:d)) then, begin
advance text box
wait(1)
set on keypress script( 21)
end
end #end of the script |
I'm not sure if the wait command in there is needed, but I'd include it just to be safe. You do not need a space bar check; the suspend box advance, combined with your previous suspend player, effectively turns the space bar off os you don't need to worry about it. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
| Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Mar 31, 2007 10:42 pm Post subject: |
|
|
Ok! I've made some tests and it nearly works each time I test. Hurra!
The only thing that left is that I can make disappear the text box using both d and space bar.
| Code: |
--------------------------------------------------------
script, talkwithD, begin #extract of talkwithD
case(9) do, begin
set npc direction (9, (MyDirection+2,mod,4))
show text box (78)
wait for key (key:d)
advance text box
wait(1)
set on keypress script( 21)
resume box advance
end
end #end of plotscript
#-----------------------------------------------------------
script, mykeypresswhilespeaking, begin
if (key is pressed (key:d)) then, begin
suspend box advance
suspend player
advance text box
wait(1)
set on keypress script( 21)
resume player
resume box advance
end
if (key is pressed (key: space)) then, begin
suspend box advance
suspend player
wait (1)
end
end #end of plotscript
#-----------------------------------------------------------
|
As I'm not very good with the wait for key commands would somoene had any idea on how to implement line code that temporaly prevents the space bar from beeing efficient?
It's rather incredible: when we don't need it we make fake freezing with a bad use of the suspend command and when we need it, we can't
Anyway thanks once more for answering so quickly!
Good luck in writing your plotscripts! _________________ It's time to make games! |
|
| Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Sun Apr 01, 2007 2:53 am Post subject: |
|
|
| Put a "suspend box advance" before the "show textbox (78)" in the talkwithD script. Hell, just put it at the top of the script. The other script isn't really necessary, I don't think, not with the "wait for key (key:d)". Just make sure the "resume box advance" is at the end of the script, not the end of the conditional, like with the other resumes. |
|
| 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
|