Resource.open - how to get it to work?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Resource.open - how to get it to work?

AndyS
Hi all
        I'm trying to get a sample working, where I just display a resource on the screen. My sample code is below - the problem is that the resource.open just returns nil.

        I've tried all sorts of combinations of parameters - none of them worked. Does anyone know how  I setup a resource in tbmpedit and then open it in Lua?

        I'm trying to get a sprite working - but the resource.draw doesn't work either - any help gratefully received.

        Btw - I will be posting a tutorial - if I get this to work.

        Cheers
                Andy Stratton
-- sprite.lua
buf=buffer.new(320,320)
sprite.init(buf)
rn=resource.open("Rsrc",-2080388892)--,"HS2Icons")
--also tried rn=resource.open("Rsrc",1000), etc.
print(rn) -- prints nil
--resource.draw(rn)
sdt={
  x=100,
  y=100,
  bitmap=bmp,
  active=true
}
sprite.add(1,sdt)
sprite.update()
gui.event()

Reply | Threaded
Open this post in threaded view
|

Re: Resource.open - how to get it to work?

ygfz4v902
I don't know how you set it up in TBmpEdit, but you have to find out
the resource ID of the bitmap. A tool I have found absolutely vital
for this kind of thing is <a
href="http://www.ppcompiler.org/download.php?lng=en">BIRD</a>, a
resource editor that allows you to see every .pdb on the palm, and go
in and view/edit all the resources (obviously, don't edit things in
other applications unless you know what you're doing). The syntax for
resource.open will be

bmp = resource.open("Tbmp", <resource id>, "<database containing bitmap>")

--- In [hidden email], <andy@...> wrote:
>
> Hi all
> I'm trying to get a sample working, where I just display a resource
on the screen. My sample code is below - the problem is that the
resource.open just returns nil.
>
> I've tried all sorts of combinations of parameters - none of them
worked. Does anyone know how  I setup a resource in tbmpedit and then
open it in Lua?
>
> I'm trying to get a sprite working - but the resource.draw doesn't
work either - any help gratefully received.

>
> Btw - I will be posting a tutorial - if I get this to work.
>
> Cheers
> Andy Stratton
> -- sprite.lua
> buf=buffer.new(320,320)
> sprite.init(buf)
> rn=resource.open("Rsrc",-2080388892)--,"HS2Icons")
> --also tried rn=resource.open("Rsrc",1000), etc.
> print(rn) -- prints nil
> --resource.draw(rn)
> sdt={
>   x=100,
>   y=100,
>   bitmap=bmp,
>   active=true
> }
> sprite.add(1,sdt)
> sprite.update()
> gui.event()
>


Reply | Threaded
Open this post in threaded view
|

re: Re: Resource.open - how to get it to work?

AndyS
In reply to this post by AndyS
"zapguyd" <[hidden email]> wrote:
>bmp = resource.open("Tbmp", <resource id>, "<database containing bitmap>")

Brilliant - got it working now - it was the "Tbmp" bit that fixed it.

Cheers
        Andy Stratton