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

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Dec 10, 2011 12:26 am Post subject: Problem with an active key when game starts |
|
|
Hello! It's me again
I managed to solve my problem with the blank line on my menu by changing the order of the command lines! Thanks to mswguest for his suggestion which was the right one!
Now I would like to deal with another problem. I'm implemented a pause in my game using the num lock key (in which was also written pause in the od keyboards)
My problem is the following : when the player takes control just after the intro script, I get on screen the message "onkeypressed script, interpreter overload".
Indeed this is because my numlock key is active because I recently keyed in numbers with numpad.
If I unactivate manually the keylock key before the game starts everthing is fine and the problem disappears.
One of the solution to solve this would be to use another key of the keyboard : like the letter P but the problem would the same if the player for strange reasons presses P as the intro scripts runs.
My question is the following : is it possible to use the key commands to detects if num lock key is active and to skip the pause script? If I could do this the pause would not overload and the error message would disappear.
(even if and especially if the player let his/her numlock key active)
I only need to do this each time the player starts to play. Do you think it is possible to do that using plotscripting?
Thanks a lot in advance for your help! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Dec 10, 2011 6:17 pm Post subject: |
|
|
You get this error because your onkeypress script contains a wait command. Get rid of it or change your script. Post your script here if you don't know how to do that.
Changing to a different key will not fully fix the problem, because it will still happen if the player holds down that key (which I admit is unlikely).
By the way, in recent versions you can use "key:Pause" instead of "key:Numlock", this new scancode isn't shared with the Numlock key. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Wed Dec 14, 2011 10:15 pm Post subject: Here is the script |
|
|
As you request here is the script that is launched when the game start
Code: |
plotscript, launch game, begin
suspend player #the player shouldn't be able to move during the title, duh...
show backdrop (0) #show absolutely nothing
set variable (MyPicSet, get hero picture(me)) #permet d'enregistrer notre apparence
set variable (MyPal, get hero palette(me))
set hero picture (me, 0) # main hero became invisible mode and is placed near the menu
set hero palette (me, 1)
fade screen out
wait(1) #this is to avoid the initial fade-in
do, begin
if(wait and listen(15)) then (break) #waiting a few seconds before displaying anything never hurts
show backdrop (3)# FooBar Studios
wait(1)
fade screen in
if(wait and listen(30)) then (break)
fade screen out
show backdrop (6)# created with the OHR
wait(1)
fade screen in
if(wait and listen(30)) then (break)
end
fade screen out
show map # no screenshot for title screen needed. prevents from seeing the menu
#play song(song:title) #play the title theme
wait(1)
fade screen in
variable(waiting)
waiting:= true
while(waiting) do, begin #these simulate the regular behaviour of the title screen
wait (1)
if(key is pressed(28)) then (waiting:= false) #ENTER
if(key is pressed(57)) then (waiting:= false) #SPACE
if(key is pressed(1)) then (fade screen out, game over) #ESCAPE
end
open menu (3)
end #end for the script
|
And here is my key is pressed script
Code: |
#-----------------------------------------------------------
plotscript, keyispressed script, 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
end #end for the script
#-------------------------------------------------------
#Dans ce script on met le jeu en pause
plotscript, pause script, begin
suspend player
suspend npcs
show text box (6) #pause
suspend box advance
day:= days of play
hour:= hours of play
minute:= minutes of play
savetime:= read general (54) #ToDo: make an official seconds of play command
pauseisactive:=true
wait(1)
end #end of the plotscript
#---------------------------------------------------------------------------
plotscript, unpaused script, begin
while (pauseisactive) do, begin
wait (1)
advance text box
write genera l(51, day) #ToDo: Make official set days of play, etc. commands
write general (52, hour)
write general (53, minute)
write general (54, savetime)
resume box advance
resume player
resume npcs
pauseisactive:=false
wait(2)
end #end of the while pause is active
end #end of the plotscript
#-----------------------------------------------------------
|
As you can see there are some wait commands but they are needed (just after turning false a global variable for example).
Any idea to create a new version of the script is welcome!
Have a nice day! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed Dec 28, 2011 2:41 am Post subject: |
|
|
Hi, sorry for the delay, largely because I was at a conference for a week, and CP has been down.
There's no reason to have wait commands in those scripts. Also, you should use key:Pause instead of key:Numlock (though I'm not sure key:Pause will work either), and keyval instead of keyispressed:
Code: | #-----------------------------------------------------------
plotscript, keyispressed script, begin
if (keyval(key: pause) >> 1) 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
end #end for the script
#-------------------------------------------------------
#Dans ce script on met le jeu en pause
plotscript, pause script, begin
suspend player
suspend npcs
show text box (6) #pause
suspend box advance
day:= days of play
hour:= hours of play
minute:= minutes of play
savetime:= read general (54) #ToDo: make an official seconds of play command
pauseisactive:=true
end #end of the plotscript
#---------------------------------------------------------------------------
plotscript, unpaused script, begin
while (pauseisactive) do, begin
advance text box
write genera l(51, day) #ToDo: Make official set days of play, etc. commands
write general (52, hour)
write general (53, minute)
write general (54, savetime)
resume box advance
resume player
resume npcs
pauseisactive:=false
end #end of the while pause is active
end #end of the plotscript
#----------------------------------------------------------- |
I'm still not sure that this script will work. Maybe I should try it myself. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Mon Jan 16, 2012 4:50 am Post subject: Thanks for your help! |
|
|
Hi, sorry for the delay, largely because I was at a conference for a week, and CP has been down.
-> please don't apoligise! You helped me so much. I don't mind waiting a week or two for an answer!
I've tested your script and it works very well! Thanks to this script it really look like the bitset "pause outside battle" had been implemented!.
Sorry but again I need you help to implement a game menu. It is the one of RPG Maker
Here is a screen
http://www.mediafire.com/i/?kx073t8swekvs72
I've managed to make all the left part (gold menu items...) but what I can't figure out is the right part and how to make appear the heroes datas. I've tried with a menu but the first line of the menu was always highlighted. I need to highlight changing the background color, not using the first menu line.
Hero portaits are with the small ennemy sprite command
Other things to be taken into account is that player datas will change all along the game...
Any suggestion is very welcome!
Anyway, Happy New Year 2012 to you and to everybody and have a nice day! _________________ It's time to make games!
Last edited by bis_senchi on Tue Jan 24, 2012 9:58 pm; edited 1 time in total |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Jan 19, 2012 10:23 pm Post subject: |
|
|
Ah, good to hear that it works.
---
Yes, custom menus aren't very flexible. You would need to use a scripted slice-based menu system. Actually I want to extend custom menus to be slice based, allowing that sort of menu, and had been working on that a couple of months ago. I might try to implement that in the new few days, but since the menu contents would have to be generated by script anyway, it might not save you much work. I'll have to get back to you about that, hope you don't mind waiting. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Tue Jan 24, 2012 9:57 pm Post subject: No problems! |
|
|
No problems at all with waiting a week or two!
When you think the line codes are efficient fell free to add them into the wip version and leave a message here.
Speaking about custom, I noticed that a new line "slice collection" has appeared. Could you please tell me why menu have been implemented?
Thanks for your help and have a nice day! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Jan 26, 2012 12:38 am Post subject: |
|
|
The slice collection editor has been there quite a long time; since before Zenzizenzic. It's used to layout slices which you can then load in-game using the 'load slice collection' command. If you don't know what slices are, look at the 'Slices' page on the wiki. The slice collection editor is most useful for things like menus. If you want some examples, I suggest looking through the slice collections in Mr. The Hamster's Math Class _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Sat Feb 11, 2012 9:05 pm Post subject: And once again... a question |
|
|
Thanks for making me noticing this game! Slice Collection seems to be very interesting. I don't know if I'm going to use them but it worths nothing it exists.
Once again I've got a problem with a "call chain script" which means my scripts overloading.
When I had this problem with the menu I found a way to prevent it using the following line
handle:= find menu ID (1)
if (handle) then (close menu (handle))
I was giving Hspeak the menu number, it checked if the menu was opened or not, andn if it was opened, I asked to close it.
I would like to do the same for my slice
if (player menu) then (free slice (player menu))
(player menu creating with player menu:= create rect (200, 150, 0))
and for my sprites
if (sl) then (free sprite (sl))
#sprites created with sl := load small enemy sprite (1,3)
if (sl2) then (free sprite (sl2))
#sprites created with sl2 := load small enemy sprite (2,1)
My question is the following : what is the equivalent for slices and sprites
of "find menu ID"?
As always thanks a lot in advance for your help! _________________ It's time to make games! |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Fri Feb 24, 2012 10:33 pm Post subject: So any idea? |
|
|
So? Does anybody has an idea about this? Is it possible to do it? _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Feb 25, 2012 2:44 am Post subject: |
|
|
Oh! Sorry, I never noticed your last message!
There is a command to check whether a slice handle exists, "slice is valid". Using this command, you can avoid causing error messages to be displayed. However there is a problem: once a slice is deleted, its handle can be reused for a different slice! So if you write
Code: | if (slice is valid (player menu)) then (free slice (player menu)) |
then you might actually be deleting a completely different slice!
One solution is to do the following instead:
Code: | if (slice is valid (player menu)) then (
free slice (player menu)
player menu := 0
) |
Since no slice ever has a slice handle of 0. And anywhere else where you delete the 'player menu' slice, also add "player menu := 0".
There is another option that is less error-prone and more similar to "find menu ID". You can assign a unique lookup code to a slice. You can edit lookup codes in the slice collection editor by editing any slice and pressing Enter on "Lookup Code". Add a "Player Menu" lookup code, then export the .HSI file for the game.
Code: | player menu:= create rect (200, 150, 0)
set slice lookup (player menu, sli:Player menu) |
and later:
Code: | variable (sl)
sl := lookup slice (sli:Player menu)
if (sl) then (free slice (sl)) |
In fact, now you don't even need the "player menu" variable anymore! You could replace "player menu" with "lookup slice (sli:Player menu)" everywhere.
It's not necessary to name a lookup code in the slice collection editor, but it's a good idea. You can use defineconstant instead.
-----
I said that we wanted to make all menus slice-based, which would make them easier to customise with scripts. Well, after discussing it on the developer mailing list for two weeks, I'm ready to start work on it. But it would not make the menu that you want much easier to create; it would still require scripting to create. So just go ahead with scripting it.
However, I'll give you a suggestion for creating the menu. Create the layout of the individual menu items in the slice collection editor. Tag each part of it (like the portrait, and the HP text slice) with lookup codes, like this:
Then use a script something like this to create each menu item:
Code: | script, add hero to menu, who, begin
variable (collection, sl)
collection := load slice collection (##)
sl := lookup slice (sli: hero menu name, collection)
get hero name (0, who)
set slice text (sl, 0)
sl := lookup slice (sli: hero menu HP, collection)
$0 = "HP: "
append number (0, get hero stat (who, stat:hp, current stat))
$0 + "/"
append number (0, get hero stat (who, stat:hp, maximum stat))
set slice text (sl, 0)
# Also set the portrait and whatever else
# ...
set slice parent (collection, MENU CONTAINER)
end |
I should put this on the wiki... _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Thu Mar 01, 2012 10:14 pm Post subject: I managed to use the slice collection menu |
|
|
I managed to use the slice collection menu! To make appear the slice I've created I need set slice look up right?
How does this command works? Do I need to get right of the line global variable (player menu)
Isn't it a problem to have 2 things with the same name?
set slice lookup (player menu, sli:Player menu)
set slice look up (global variable, name/ id on the slice collection menu?)
Thanks a lot for your help! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Mar 03, 2012 7:34 am Post subject: |
|
|
Lookup codes are used only by the "lookup slice" command. Currently they have no other use. I used lookup codes to find slices in the slice collection which I wanted to modify.
Lookup slice has a second argument, which allows you to restrict the search just to the child (and grandchild and great-grandchildren...) of a particular slice. It's OK to give multiple slices the same lookup code if you use this.
No, you don't need to get rid of "global variable (player menu)". I was just suggesting that it's possible. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
bis_senchi

Joined: 08 Jun 2004 Posts: 460 Location: Reims, France
|
Posted: Wed Mar 07, 2012 3:42 am Post subject: I've managed to create a collection but |
|
|
Following your advice I've managed to create a slice collection but I can't make appear my portrait above my menu .
The one I've made is kept under the slice used for the menu body.
I also have this pb with my text slice.
Could you please tell me how am I supposed to make appear my sprite slice above my rect slice?
Thanks a lot in advance for your help! _________________ It's time to make games! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Mar 10, 2012 3:29 pm Post subject: |
|
|
Child slices are always drawn on top of their parent. Normally to cause a slice to be drawn over a rect slice, you would make the slice a child of the rect slice, like this:
Code: | variable (rect, slice)
rect := create rect (...)
slice := load portrait sprite (...)
set parent (slice, rect) |
You can also make one slice appear above another by moving it afterwards the other in the slice tree, but sharing the same parent. You can use the "move slice above" command for that. _________________ "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
|