Teaser for a game I'm working on...
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Teaser for a game I'm working on...
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.
- 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...
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.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.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Teaser for a game I'm working on...
And if it succeeds, I won't have to call it again, right?Robin wrote: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.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.
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)
Code: Select all
success, result = pcall(createBuffers())
What's up with the second one? Do I need to leave the () off? What if I need to pass variables to the function?
- 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...
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.
The first will error, the second will return false, "Demo".
Code: Select all
--from
error("Demo")
--to
pcall(error, "Demo")
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Teaser for a game I'm working on...
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
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.
Who is online
Users browsing this forum: No registered users and 1 guest