Page 35 of 91

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

Posted: Thu May 21, 2015 7:41 am
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.

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

Posted: Thu May 21, 2015 6:33 pm
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

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

Posted: Thu May 21, 2015 6:57 pm
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

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

Posted: Wed May 27, 2015 5:45 pm
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?

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

Posted: Wed May 27, 2015 8:41 pm
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

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

Posted: Thu May 28, 2015 7:06 am
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

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

Posted: Tue Jun 02, 2015 6:13 pm
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.

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

Posted: Tue Jun 02, 2015 7:45 pm
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. ;)

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

Posted: Thu Jun 04, 2015 6:50 pm
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)

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

Posted: Thu Jun 04, 2015 7:46 pm
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?