jason215
August 30th, 2006, 10:28
hi,
if got some problems whith my lua script
(dont get angry because im a bit noob with lua)
but if somebody can look at it thnx i appriciatet it
*srry 4 my bad english :(
anyways i'm always getting this error
error: index.lua:81: bad argument #2 to 'blit' (image expected, got table)
here's the code
-- images
background=Image.load("back.jpg")
player1 = Image.load("Naruto.png")
shadow = Image.load("shadow.png")
-- player 1
player={}
player.gravity = 200
player.x = 50
player.y = 250
player.jumpspeed = 10
player.jumpstate = "ground"
-- player 2
shadow={}
shadow.x = 30
shadow.y = 230
-- controls
function controls()
pad=Controls.read()
end
while true do
controls()
screen:blit(0,0,background,false)
controls()
if pad:right()then
player.x = player.x + 4
shadow.x = shadow.x + 4
end
if pad:left()then
player.x = player.x - 4
shadow.x = shadow.x - 4
end
-- jumping script
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"
end
if player.jumpstate == "jumping"
then player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 200 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 200 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 200 then player.gravity = 200
end
player.y = player.gravity
--end jumpscript
-- Shadow Replication Script
screen:blit(shadow.x,shadow.y,shadow)
-- End Shadow script
screen:blit(player.x,player.y,player1)
screen.waitVblankStart()
screen.flip()
end
if got some problems whith my lua script
(dont get angry because im a bit noob with lua)
but if somebody can look at it thnx i appriciatet it
*srry 4 my bad english :(
anyways i'm always getting this error
error: index.lua:81: bad argument #2 to 'blit' (image expected, got table)
here's the code
-- images
background=Image.load("back.jpg")
player1 = Image.load("Naruto.png")
shadow = Image.load("shadow.png")
-- player 1
player={}
player.gravity = 200
player.x = 50
player.y = 250
player.jumpspeed = 10
player.jumpstate = "ground"
-- player 2
shadow={}
shadow.x = 30
shadow.y = 230
-- controls
function controls()
pad=Controls.read()
end
while true do
controls()
screen:blit(0,0,background,false)
controls()
if pad:right()then
player.x = player.x + 4
shadow.x = shadow.x + 4
end
if pad:left()then
player.x = player.x - 4
shadow.x = shadow.x - 4
end
-- jumping script
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"
end
if player.jumpstate == "jumping"
then player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 200 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 200 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 200 then player.gravity = 200
end
player.y = player.gravity
--end jumpscript
-- Shadow Replication Script
screen:blit(shadow.x,shadow.y,shadow)
-- End Shadow script
screen:blit(player.x,player.y,player1)
screen.waitVblankStart()
screen.flip()
end