hmmm, are u sure u have saved everything in the right place etc...
Printable View
hmmm, are u sure u have saved everything in the right place etc...
did you rename it to .lua ? maybe that's why
I put my Index.lua in a folder by the name of "Test"
That should work as it's exactly the helloworld tutorial. What mako said could be your problem. If that still doesn't work, you should check if your extensions are hidden. Incase you don't know, you do that like this:Zitat:
Zitat von Shadox75
1) In explorer, click on extra, or I belive it's tools in english.
2) Click mappreferences
3) Click the second tab (dont know what its in english, but there is a long checklist)
4) In the Dutch version its the 7th from above. It says "hide extensions for known filetypes" or something like that. Uncheck that.
5) Now rename the file again to a .lua file.
is it possible for me to edit a variable by adding another variable? like
Code:n=0
for n = 0,70 do
if collision(playerX, playerY, 32, 32, solidX.n, solidY.n, 16, 16) then
vspeed=0
end
end
or
Code:-- the map
map = {
"a a",
"a aaaaaa",
"a a",
"a a",
"a a",
"a a",
"a aaaaaa",
"a a",
"a a",
"a a",
"a aa a",
"a a",
"a a",
"a aa a",
"a a",
"a a",
"cccccccccccccccccccccccccccccc",
}
-- offsreen image, where the map will be drawn
board = Image.createEmpty(480, 272)
function drawTile(tile, x, y)
local tileX = math.mod(tile, 3)
local tileY = math.floor(tile / 3)
board:blit(16 * x, 16 * y, tiles, 16 * tileX , 16 * tileY, 16, 16, false)
end
n=0
board:blit(0, 0, background, false)
for y = 1, 17 do
line = map[y]
for x = 1, 30 do
solidX.n = x*16
solidY.n = y*16
tile = string.byte(line, x) - string.byte("a")
drawTile(tile, x - 1, y - 1)
n=n+1
end
end
the error I get is that solidX is a nil value. i
s there any way for me to do solidX.n or solidX[n] or solidX+string(n) so i can edit the name of the solidX variable on the fly? none of the above work
Under properties it says "LUA file".
Does it matter if the lua file is index.lua or does it have to be script.lua.
I have 2.60, is that the problem?
no the name of the lua file doesn't matter. Mine are never index.lua now i come to think of it. Its always something like main.lua or game.lua or whatever. I dont know if it matter is you have 2.60 or any other firmware. I think it should just work though.
@Mako: Wher do you get the error?
hmmm, i dont know then.
it seems to be right
it just might. have you tried using it on luaplayer for windows? if u don't have that
heres the link
||
\ /
http://www.luaplayer.org/luaplayerwindows-0.14.zip
Double Post Merge
I'll just post my entire game code:
Code:-----------------------------------------------------------------Initiate
----Functions:
function collision(x1, y1, w1, h1, x2, y2, w2, h2)
if (y2 >= y1 and y1 + h1 >= y2) or (y2 + h2 >= y1 and y1 + h1 >= y2 + h2) or (y1 >= y2 and y2 + h2 >= y1) or (y1 + h1 >= y2 and y2 + h2 >= y1 + h1) then
if x2 >= x1 and x1 + w1 >= x2 then
return true
elseif x2 + w2 >= x1 and x1 + w1 >= x2 + w2 then
return true
elseif x1 >= x2 and x2 + w2 >= x1 then
return true
elseif x1 + w1 >= x2 and x2 + w2 >= x1 + w1 then
return true
end
end
return false
end
----resources:
green = Color.new(0,100,0)
red = Color.new(200,0,0)
background=Image.load("background.png")
orb=Image.load("orb.png")
tiles=Image.load("blocktile.png")
sndjump= Sound.load("jump.wav")
blueblock= Image.load("blue.png")
----background music:
Music.playFile("amazon.xm",true)
Music.volume(128)
screen:clear()
----Init Variables
-- the map
map = {
"a a",
"a aaaaaa",
"a a",
"a a",
"a a",
"a a",
"a aaaaaa",
"a a",
"a a",
"a a",
"a aa a",
"a a",
"a a",
"a aa a",
"a a",
"a a",
"cccccccccccccccccccccccccccccc",
}
-- offsreen image, where the map will be drawn
board = Image.createEmpty(480, 272)
function drawTile(tile, x, y)
local tileX = math.mod(tile, 3)
local tileY = math.floor(tile / 3)
board:blit(16 * x, 16 * y, tiles, 16 * tileX , 16 * tileY, 16, 16, false)
end
n=0
board:blit(0, 0, background, false)
for y = 1, 17 do
line = map[y]
for x = 1, 30 do
solidX[n] = x*16-----------------I get the error right here
solidY[n] = y*16
tile = string.byte(line, x) - string.byte("a")
drawTile(tile, x - 1, y - 1)
n=n+1
end
end
-- current player position
playerX = 416
playerY = 192
vspeed=0
-- current player animation image
animation = 0
-- 1 = animation images increases, -1: decreases
animationDirection = 1
-- animation slowdown counter
animationSlowDown = 0
---------------------------------------------------------------------------Main loop
while true do
------------------------------------controls
pad = Controls.read()
if pad:select() then
Music.stop()
break
end
if pad:left() then
n=0
for n = 0,70 do
if collision(playerX-4, playerY,32,32, solidX[n], solidY[n], 16, 16) then
playerX=playerX-4
end
end
end
if pad:right() then
n=0
for n = 0,70 do
if collision(playerX+4, playerY, 32,32, solidX[n], solidY[n], 16, 16) then
playerX=playerX+4
end
end
end
if pad:up() then
if collision(playerX, playerY+1,32,32, 0, 256, 480, 16) then
sndjump:play()
vspeed=-10
end
end
----------------------------------Gravity and friction
playerY=playerY+vspeed
if not collision(playerX, playerY+1,32,32, 0, 256, 480, 16) then
vspeed=vspeed + 0.5
else
vspeed=0
end
if vspeed <= -12 then
vspeed=-12
end
if vspeed >= 12 then
vspeed=12
end
-----------------------------------Collision Detection:
-------------if floor collision
--if collision(playerX, playerY+1, 32, 32, 0, 256, 480, 16) then
--vspeed=0
--end
n=0
for n = 0,70 do
if collision(playerX, playerY, 32, 32, solidX[n], solidY[n], 16, 16) then
vspeed=0
end
end
prevx=playerX
prevY=playerY
------------------------------------------Draw Images:
screen:blit(0, 0, board, 0, 0, board:width(), board:height(), false)
-- blit current player animation image
Image:blit(playerX , playerY, orb, 32 * animation, 1, 32, 32,true)
-- calculate next animation image
animationSlowDown = animationSlowDown + 1
if animationSlowDown == 3 then
animationSlowDown = 0
animation = animation + animationDirection
if animation == 6 then
animation = 0
end
end
screen.waitVblankStart()
screen:flip()
end
i'm using n to begin with to store the x,y info for each solid tile, so when it draws the tile, it saves the x,y info used in solid[n] you get me how an array works?
Can I upload my file so someone else can try it?