"Questions that don't deserve their own thread" thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: "Questions that don't deserve their own thread" thread

Post by szensk »

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

Re: "Questions that don't deserve their own thread" thread

Post by dubem »

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
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: "Questions that don't deserve their own thread" thread

Post by Positive07 »

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/pablomayobre)
dubem
Prole
Posts: 8
Joined: Fri Mar 27, 2015 1:42 pm

Re: "Questions that don't deserve their own thread" thread

Post by dubem »

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?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: "Questions that don't deserve their own thread" thread

Post by Positive07 »

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/pablomayobre)
User avatar
Ortimh
Citizen
Posts: 90
Joined: Tue Sep 09, 2014 5:07 am
Location: Indonesia

Re: "Questions that don't deserve their own thread" thread

Post by Ortimh »

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
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Re: "Questions that don't deserve their own thread" thread

Post by Jack Dandy »

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.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: "Questions that don't deserve their own thread" thread

Post by I~=Spam »

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

Re: "Questions that don't deserve their own thread" thread

Post by Whatthefuck »

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)
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: "Questions that don't deserve their own thread" thread

Post by Positive07 »

Whatthefuck wrote: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)
Does setting [wiki]love.graphics.setDefaultFilter[/wiki] not work?
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Locked

Who is online

Users browsing this forum: No registered users and 5 guests