| View previous topic :: View next topic |
| Author |
Message |
mako
Joined: 21 Feb 2006 Posts: 4
|
Posted: Tue Feb 21, 2006 8:22 am Post subject: error: (a nil value) |
|
|
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... |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Tue Feb 21, 2006 8:42 am Post subject: |
|
|
TTF support (v0.16) is not available in windows luaplayer (v 0.14).
See: http://www.luaplayer.org/
Lee |
|
| Back to top |
|
 |
mako
Joined: 21 Feb 2006 Posts: 4
|
Posted: Tue Feb 21, 2006 8:47 am Post subject: |
|
|
| 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... |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Tue Feb 21, 2006 8:58 am Post subject: |
|
|
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?t=4712&highlight=bitmap+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: |
function Font.load(fontName)
io.write("Stubbed font load function.\n")
end
|
|
|
| Back to top |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Tue Feb 21, 2006 9:27 am Post subject: |
|
|
| -ignore this post- |
|
| Back to top |
|
 |
mako
Joined: 21 Feb 2006 Posts: 4
|
Posted: Tue Feb 21, 2006 1:55 pm Post subject: |
|
|
| 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?t=4712&highlight=bitmap+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: |
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 :( |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Tue Feb 21, 2006 3:16 pm Post subject: |
|
|
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: |
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: |
while true do
pad=Controls.read()
if(pad ~= oldpad) then
oldpad=pad
if pad:start() then
elseif pad:cross() then
---etc
end
end
end
|
|
|
| Back to top |
|
 |
|