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

Joined: 24 Nov 2009 Posts: 43
|
Posted: Thu Feb 11, 2010 6:16 pm Post subject: Debug error re: slices |
|
|
I am making a slice based fuel gauge. By all tests, it seems to be working beautifully.
Thing is, the bloody debugger insists that I've done something wrong with this message:
Code: | Script Error!
setsliceheight: invalid slice handle 0
Call chain (current script last):
usegas |
I've tried half a dozen approaches to deal with it, and all I've gained is a headache.
Here's the relevant code:
Code: |
global variable (3,gastank)
#-----------------------------------------------------
#This is the fuel gauge. Autoloads on map.
#Black rectangle 100px high for the background,
#Red rectangle 25px on top of black,
#Blue rectangle 1px high per item of gas +1 (max 100) over red
#Text slice label FUEL over blue
plotscript, setup HUD, begin
get item (item:Gas,99) #For testing purposes!
variable(black)
black := create rect (10, 100, 14)
realign slice (black, edge:right, edge:bottom, edge:right, edge:bottom)
variable(red)
red := create rect (10, 25, 2)
set parent (red, black)
realign slice (red, edge:right, edge:bottom, edge:right, edge:bottom)
gastank := create rect (10, (inventory (item:Gas) + 1), 0)
set parent (gastank, black)
realign slice (gastank, edge:right, edge:bottom, edge:right, edge:bottom)
variable(text)
text := create text
set parent (text, black)
set wrap(text)
set slice width(text, 8)
set text color(text, 0)
$1=" Fuel "
set slice text(text, 1)
realign slice (text, edge:right, edge:top, edge:right, edge:top)
end
#-----------------------------------------------------
#Each step uses one unit of gas, blue gas gauge resized to reflect this.
plotscript, use gas, begin
delete item (item:Gas)
set slice height(gastank, (inventory (item:Gas) + 1))
end
|
Any ideas how to kill this nuisance? |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Thu Feb 11, 2010 7:22 pm Post subject: |
|
|
My first guess is that use gas is running before setup HUD has a chance to create the gas tank slice.
Try this:
Code: |
plotscript, use gas, begin
if(gastank) then(
delete item (item:Gas)
set slice height(gastank, (inventory (item:Gas) + 1))
)
end |
|
|
Back to top |
|
 |
mjkrzak

Joined: 24 Nov 2009 Posts: 43
|
Posted: Fri Feb 12, 2010 4:16 pm Post subject: |
|
|
Yup, that was the issue. Never considered that Each Step scripts took precedence over Autorun ones. |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Feb 12, 2010 7:29 pm Post subject: |
|
|
The map autorun gets triggered first, when the map loads. Then the step through the door that took you to the map (or the placement of the hero on the starting map) triggers an each-step which causes the map autorun to get paused.
Silly, I know :) |
|
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
|