Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Here's an example, basically right from the Lua manual:

Code: Select all

local function printlocals()
local n = 1
while true do
local name, value = debug.getlocal(2,n)
if not name then break end
print(name, value)
n = n + 1
end
end

do
g = 1
local l = 2
printlocals()
end

If you wanted to something other than print them, you may want to store them in a table. You may want to get upvalues as well. See the manual for a more complete solution.

dubem
Prole
Posts: 8
Joined: Fri Mar 27, 2015 1:42 pm

Hey gang!

Is it possible to loop through a matrix one step every update?

like:

update 1: matrix[1][1]
update 2: matrix[1][2]
update 3: matrix[2][1] and so forth

Have a nice day!

-- Alex

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

dubem wrote:Hey gang!

Is it possible to loop through a matrix one step every update?

like:

update 1: matrix[1][1]
update 2: matrix[1][2]
update 3: matrix[2][1] and so forth

Have a nice day!

-- Alex
something like:

Code: Select all

local i = 1
local j = 0
local matrix = {{1,1,2,3,2,3,1,1,3,2},{1,2,2,2,3,1,4,1,1,1,2,3,2},{1,1,2,3,4,1,1,1,1,1,2},{1,1,1,2,2,3,1,3,1,3,2}}

function love.update (dt)
j = j + 1
if j > #matrix[i] then j,i = 1, i+1 end
print("update: "..matrix[i][j])
end

for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

dubem
Prole
Posts: 8
Joined: Fri Mar 27, 2015 1:42 pm

Thanks man!

Another question: I want to know when/where an object goes over the window borders. Without a camera it is easy. But what how do I know with moving camera?

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

dubem wrote:Thanks man!

Another question: I want to know when/where an object goes over the window borders. Without a camera it is easy. But what how do I know with moving camera?
Well you should make an issue for that, since I dont know what you have and what you are missing, try creating an issue in the Support and Development forum and attach your code using [ code ] [ / code ] tags or preferably an attachment with your .love file so that we can easily find your issue.

PS: I recommend you take a look at gamera
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

Ortimh
Citizen
Posts: 90
Joined: Tue Sep 09, 2014 5:07 am
Location: Indonesia

dubem wrote:Another question: I want to know when/where an object goes over the window borders. Without a camera it is easy. But what how do I know with moving camera?
I suggest you to use Kikito's Gamera as your camera. If you use it then use toScreen method to know the object position in the camera.

Code: Select all

local x, y = gamera:toScreen(object.x, object.y)

if (not ((x >= 0 and x <= love.window.getWidth()) and (y >= 0 and y <= love.window.getHeight()))) then
-- do your stuff if the object goes over the window borders
end

Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Heya, I need a suggestion:
When I run into some kind of "freezing" error in my game, what's the best way to debug it?

Using Ctrl+F5 from the LUA editor (I use ZeroBrane) takes too long to reach that point.

I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Press Shift + F9 (or the pause icon in the tool bar) to pause execution where it is at and the cursor will show where the code stopped.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Is there a way to have a spritebatch use nearest filtering instead of linear? Setting the filter mode to nearest on the texture I wish to use on the spritebatch doesn't seem to work. (ie still uses linear)

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina