Hello, I have a problem with the game I am currently trying to make. More specifically I have a chunk of code that appears to cause a crash at startup. More specifically this chunk which is inside of love.update.
--set apple
if apple.spawned == false then
--is apple.x on player?
local x = 0
while x == 0 do
apple.x = love.math.random(0, (wWidth - apple.size))
if (apple.x + apple.size) < player.x or apple.x > (player.x + player.size) then
x = 1
end
end
--is apple.y on player?
local y = 0
while y == 0 do
apple.y = love.math.random(0, (wHeight - apple.size))
if (apple.y + apple.size) < player.y or apple.y > (player.y + player.size) then
y = 1
end
end
--apple has spawned
apple.spawned = true
end
What I want to do is choose a random coordinate for x and check if set position is on the player, if it is not then repeat the same for y and set the apple once things check out fine. I have sent the code to a friend of mine who has successfully executed it and played, I however could not. I tried running it using the 32-bit and 64-bit engines (love 0.9.1) to no avail. If it's of any relevance I'm running all of this on my Win7 x64 Virtual Machine on VirtualBox. I have attached the .love if you wish to check it out. Help will be greatly appreciated.
This is my first time posting on theses forums so my apologies if I haven't added something necessary for you to assist me, simply tell me and I will do my best to fill you in on the missing details.
Error: Syntax error: main.lua:53: 'then' expected near '�'
The reason is that before the "<" there is an invisible character, that looks like a " " but it isn't. To make it run, remove this invisible character and replace it by a space.
Branch Greenwood wrote:This is my first time posting on theses forums so my apologies if I haven't added something necessary for you to assist me, simply tell me and I will do my best to fill you in on the missing details.
Don't worry. You provided all necessary information.
If next time the love game immediately closes on start up, try running it from a console. That way you get an error message as text output.
micha wrote:Hi and welcome to our forum.
If next time the love game immediately closes on start up, try running it from a console. That way you get an error message as text output.
Thanks a lot for the help. How do I run my game from a console?
On Windows, you have to put a file called [wiki]conf.lua[/wiki] in the same folder as main.lua, setting the "console" property to true. On other OSes, you should call "love path/to/game/folder (or .love file)" in a terminal.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics