Teaser for a game I'm working on...

Show off your games, demos and other (playable) creations.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Teaser for a game I'm working on...

Post by Jasoco »

I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Teaser for a game I'm working on...

Post by Robin »

Jasoco wrote:I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
You could put the creation of framebuffers in a function (in a loop or whatever), and pcall that function. If it fails, you know you don't have enough framebuffers and you need to fall back to something else.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Teaser for a game I'm working on...

Post by Jasoco »

Robin wrote:
Jasoco wrote:I don't suppose that would help me if I need a specific number of buffers but the computer only allows a couple and the pcall still passes the test.
You could put the creation of framebuffers in a function (in a loop or whatever), and pcall that function. If it fails, you know you don't have enough framebuffers and you need to fall back to something else.
And if it succeeds, I won't have to call it again, right?

When you say "success, result", does that mean pcall returns true for success and whatever the result of the function is for the function as result?

Edit: Did a little test. I got two different results:

Code: Select all

success, result = pcall(createBuffers)
Returns "true, true"

Code: Select all

success, result = pcall(createBuffers())
Returns "false, attempt to call a boolean value"

What's up with the second one? Do I need to leave the () off? What if I need to pass variables to the function?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Teaser for a game I'm working on...

Post by bartbes »

I'm not sure what that createBuffers() function do, but I suspect it returns a boolean value, which pcall then tries to call. Pcall calls for you, so you don't call the function yourself.

Code: Select all

--from
error("Demo")
--to
pcall(error, "Demo")
The first will error, the second will return false, "Demo".
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Teaser for a game I'm working on...

Post by Jasoco »

Code: Select all

function createBuffers()
  fb = {
    floor = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
    objects = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
    osd = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
    rays = gr.newFramebuffer(math.max(g.w,256), math.max(g.h,256)),
    scroll = gr.newFramebuffer(math.max(g.w,512), math.max(g.h,512))
  }
  for i, f in pairs(fb) do
    f:setFilter("nearest", "nearest")
  end
  return true
end
It doesn't really need to return anything. I just return true for the hell of it.

I want to use as little buffers as possible, but still want to make as much use of them as possible. What would you say a safe number is? I'd like to use at most 8. Right now I have 5. And the first isn't really needed.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 57 guests