Hey smart people -
I have attached my .love file to make my description make sense
I'm a web application developer trying my hand at game development and I stumbled upon the Love Engine for my first go at it! But I'm having some trouble - I'm trying to write a simple typing game (ignore cheezyness please) where words fall and you have to type them correctly before they reach the bottom of the screen.
The words on screen are held in an array - I'm very familiar with arrays but not with Lua. There seems to be an error popping up in the ' keypressed' function.
When the user enters the first letter of one of the activeWords it should look through the array at all the first letters and see if they match - but the errors stops the execution and I cannot figure out how to debug it by printing to the error screen.
-Can anyone tell me how to debug the code (i.e. print to a console or error page)
-See if you can figure out what the error indicates in the code? I've attached my zipped .love file to this post
-Thanks in advance for the help!
Table Reference Issue
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Table Reference Issue
- Attachments
-
- game.love.zip
- Here is the zipped .love file.
- (2.22 MiB) Downloaded 171 times
----
LoL name: ADarkWind
Starcraft2: Axel
----
LoL name: ADarkWind
Starcraft2: Axel
----
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Table Reference Issue
Start a terminal and run LÖVE from there.hartste90 wrote:-Can anyone tell me how to debug the code (i.e. print to a console or error page)
The issue is here:hartste90 wrote:-See if you can figure out what the error indicates in the code? I've attached my zipped .love file to this post
Code: Select all
nextLetter = activeWords[i][1];
Code: Select all
nextLetter = activeWords[i]:sub(1,1)
There are other things in your code: lots of global variables that shouldn't be global (like nextLetter), you use table.getn(), which is deprecated, use the # operator instead:
Code: Select all
for i = 1, #activeWords do
Help us help you: attach a .love.
Re: Table Reference Issue
Unless you're on Windows. In that case, create a file, call it "conf.lua", place it in the same folder as your main.lua and put the following code in it:Robin wrote: Start a terminal and run LÖVE from there.
Code: Select all
love.conf = function(t)
t.console = true
end
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Table Reference Issue
But OP is on a Mac, so that's not relevant for them.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 6 guests