My code is crashing pipmak, but why?
Status: Alpha
Brought to you by:
cwalther
|
From: syxified <syx...@ya...> - 2009-09-09 20:01:18
|
The answer to this will probably be very simple, since I am no coding pro and
mostly have just fumbled my way through this, but if anyone could help me
out, it would be much appreciated. I'm working on a game, and at the moment
I'm focused on implementing an inventory overlay node that can be called
globally/toggled with the "i" key. Of course, all the individual item names
are going to have to be little patches that I will lay handles on to make
them selectable, etc. So I'm trying to get it so it arranges those patches
(items in inventory) on the overlay node sequentially based on if they are
in the players possession or not. I just introduced a 'for' loop into the
onkeydown handler to check the array of patches, and those which are found
to be true in the inventory get moved so they are in a decending order
visually on the page. However, that for loop keeps crashing pipmak the
moment I hit the "i" button. Any help would be much appreciated. So, here
is the code i have, first is Main, second is node 99, which is the inventory
overlay node:
version (0.27)
title "Dark Heart Test"
startnode (2)
state.invenOpen = false
state.Abacus = true
state.Bone = true
state.Corpse = true
readState = false
onkeydown(
function(key)
if key == string.byte("i")
then
if state.invenOpen == false
then
pipmak.overlaynode(99, dontsave)
state.invenOpen = true
itemDepth = 90
itemOffset = 20
for i=1, 3 do --change that 3 to the item table size
currentItem = itemObjectTable[i]
currentItem:move{y = itemDepth}
itemDepth = itemDepth + itemOffset
end
return true
else
inventoryNode:closeoverlay()
state.invenOpen = false
return false
end
end
end
)
--this is the inventory node 99
scrollObject = pipmak.getimage("../99/justScroll.bmp")
scrollWidth, scrollHeight = scrollObject:size()
itemObject = pipmak.getimage("../99/justItem.bmp")
itemWidth, itemHeight = itemObject:size()
itemAbacus = pipmak.getimage("../99/itemAbacus.bmp")
itemBone = pipmak.getimage("../99/itemBone.bmp")
itemCorpse = pipmak.getimage("../99/itemCorpse.bmp")
itemAllTable = {
itemAbacus,
itemBone,
itemCorpse
}
panel
{
scrollObject,
relx = .5,
rely = .5,
absx = -(.5 * scrollWidth),
absy = -(.5 * scrollHeight)
}
inventoryNode = pipmak.thisnode()
itemDepth = 40
itemOffset = 20
itemLocationTable = {
itemDepthAbacus,
itemDepthBone,
itemDepthCorpse
}
itemObjectAbacus = patch {
x = (.5 * scrollWidth) - (.5 * itemWidth),
y = itemDepth,
w = itemWidth,
h = itemHeight,
visible = state.Abacus,
image = itemAllTable[iter],
}
iter = iter + 1
itemObjectBone = patch {
x = (.5 * scrollWidth) - (.5 * itemWidth),
y = itemDepth,
w = itemWidth,
h = itemHeight,
visible = state.Bone,
image = itemAllTable[iter],
}
iter = iter + 1
itemObjectCorpse = patch {
x = (.5 * scrollWidth) - (.5 * itemWidth),
y = itemDepth,
w = itemWidth,
h = itemHeight,
visible = state.Corpse,
image = itemAllTable[iter],
}
iter = iter + 1
itemObjectTable = {
itemObjectAbacus,
itemObjectBone,
itemObjectCorpse
}
itemStateTable = {
state.Abacus,
state.Bone,
state.Corpse
}
--THAT'S IT!
Thanks in advance!
~Matt
--
View this message in context: http://www.nabble.com/My-code-is-crashing-pipmak%2C-but-why--tp25372235p25372235.html
Sent from the pipmak-users mailing list archive at Nabble.com.
|