error: (a nil value)

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
mako
Posts: 4
Joined: Tue Feb 21, 2006 8:11 am

error: (a nil value)

Post by mako »

Okay, so I can load pictures alright, but no matter what I try and change and mess about with, I can't get:

arial = Font.load("arial.ttf")

to work

I always get:

error: index.lua:10: attempt to index global `Font' (a nil value)


The font file's most defintely in the right directory, as I can load normal pictures without fail. I've tried everything. I'm using the windows LuaPlayer. Please tell me this is not a problem...


Oh and one more thing: I tried doing the cygwin tut, got up until the last step, and it told me when I tried to build it for windows: it comes up with some errors on luacontrols and missing headers and stuff like that...

Any help is gladly appreciated...
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

TTF support (v0.16) is not available in windows luaplayer (v 0.14).

See: http://www.luaplayer.org/

Lee
mako
Posts: 4
Joined: Tue Feb 21, 2006 8:11 am

Post by mako »

thank alot. How can I edit the code to prevent this error every time arial is called as a font? Can I use a different font extension? Can I somehow leave it as default. I don't wanna go through the whole code and replace "arial" with whatever I'd need...
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

I also do all my testing on the windows luaplayer, and because of that, I have avoided using any of the 0.16 features such as TTF.

If you want to write text to the screen, you'll either have to use screen:print (basic monospaced 8pixel font) or use a bitmap font (someone released a bitmap font library a while ago here).
http://forums.ps2dev.org/viewtopic.php? ... itmap+font

If you want to be able to test on the windows luaplayer whilst still using 0.16 features on the PSP, the way I see it you have 2 choices:

1. Add the features yourself to the windows luaplayer binary (non-trivial).
2. Stub out the missing functions in a seperate .lua file, and remove the stub file when deploying to PSP.

e.g. Create a function:

Code: Select all

function Font.load(fontName)
   io.write("Stubbed font load function.\n")
end
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

-ignore this post-
mako
Posts: 4
Joined: Tue Feb 21, 2006 8:11 am

Post by mako »

fullerlee wrote:I also do all my testing on the windows luaplayer, and because of that, I have avoided using any of the 0.16 features such as TTF.

If you want to write text to the screen, you'll either have to use screen:print (basic monospaced 8pixel font) or use a bitmap font (someone released a bitmap font library a while ago here).
http://forums.ps2dev.org/viewtopic.php? ... itmap+font

If you want to be able to test on the windows luaplayer whilst still using 0.16 features on the PSP, the way I see it you have 2 choices:

1. Add the features yourself to the windows luaplayer binary (non-trivial).
2. Stub out the missing functions in a seperate .lua file, and remove the stub file when deploying to PSP.

e.g. Create a function:

Code: Select all

function Font.load(fontName)
   io.write("Stubbed font load function.\n")
end
thx for the pointers. I don't quite understand what you mean with stubbing out the functions. What I did now was find and replace, it's simple enough, I just hope that the .ttf is the only problem I'll be experiencing...

Thx fo rthe help again! :)


€DIT: Is there anything I can do to slow that shit down? I tap down and it's already at the bottom :(
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

If you only want to respond once per button press (as opposed to responding each cycle if a button is down), you can either use this function (put it just after you are handling the button press, it will basically pause execution until there are no buttons pressed):

Code: Select all

function Controls.waitpadup()
   pad=Controls.read()
   while pad:select() or pad:start() or pad:up() or pad:right() or pad:down() or pad:left() or pad:l() or pad:r() or pad:triangle() or pad:circle() or pad:cross() or pad:square() do
      screen.waitVblankStart()
      pad=Controls.read()
   end
end
Or, at the start of each cycle, you can test if the pad has changed, and only respond to events if it has:
eg:

Code: Select all

while true do
   pad=Controls.read()
   if(pad ~= oldpad) then
      oldpad=pad

      if pad:start() then

      elseif pad:cross() then

      ---etc
      end
   end
end
Post Reply