Lua Player for PSP

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

Moderators: Shine, Insert_witty_name

Post Reply
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Soban wrote:For some reason there's a typo in graphics.c line 22 of the latest commit. It's trivial to fix, but annoying.
Ack! My bad, very sorry... forgot to make before commiting, very bad habit... Fixed now.
emumaniac
Posts: 79
Joined: Sun May 08, 2005 12:22 am

Post by emumaniac »

nevyn wrote:
indianajonesilm wrote:Hello all! I'm attempting to make an air hockey game.
I sorta dislike rigid movement, so I couldn't help but to add acceleration to your game :P Hope you like it :)
(Lowser-adapted it while at it, too)
http://ncoder.nevyn.nu/psp/pspairhockey.zip
anychance of merging your corrections into the original release with Eboot, so that us fans can enjoy a new game :)
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

emumaniac wrote:
nevyn wrote:
indianajonesilm wrote:Hello all! I'm attempting to make an air hockey game.
I sorta dislike rigid movement, so I couldn't help but to add acceleration to your game :P Hope you like it :)
(Lowser-adapted it while at it, too)
http://ncoder.nevyn.nu/psp/pspairhockey.zip
anychance of merging your corrections into the original release with Eboot, so that us fans can enjoy a new game :)
I recommend using Lowser instead of bundling with your very own eboot. If you install the latest LuaPlayer with the latest Lowser (probably to be released in a userfriendly binary format within a day, unless there's some bug), you can just drop that psp air hockey folder directly from the zip into the Applications folder, and it'll work, with no eboot bundling needed.

Secondly, that game needs a puck before being playable...
indianajonesilm
Posts: 15
Joined: Tue Feb 08, 2005 6:36 pm

Post by indianajonesilm »

Secondly, that game needs a puck before being playable...
I'm working on it :)

I sorta dislike rigid movement, so I couldn't help but to add acceleration to your game :P Hope you like it :)
(Lowser-adapted it while at it, too)
Thank you so much for the acceleration! woohoo! I love it.
would there be hard slap shots that would knock the disc/puck off the table? that could be some interesting play lol
Hey thats a good idea. Maybe in a future release. I still have to figure out all this collision detection and motion vector stuff first.
Mr_Snuffle
Posts: 1
Joined: Wed Aug 10, 2005 9:59 pm
Location: Brisvagas, 'Straya

Post by Mr_Snuffle »

InputManager library

I'm working on an InputManager library for lua, and I'm currently in the last steps of bug fixing for the new version of lua player. What are peoples thoughts on the interface. I'm open to suggestions

Code: Select all

The Most Excellent PSP Lua Input Mananager 0.1

Author: James Bowling ([email protected])
Date: 5 Aug 05

ABOUT

In an effort to make some more friendly event driven input management, I've put together this
fairly simple wrapper around the Luaplayer input functions. It allows the user to register
callback functions with different events on different buttons, deregister these events, and
check if a button is currently pressed

TODO

	* Add analog stick support when I figure out exactly how I can do that
	* Have friendly support for diagonal directions

CONSTANTS

Events:
	INPUT_EVENT.PRESS
	INPUT_EVENT.RELEASE

Keys:
	INPUT_KEY.UP
	INPUT_KEY.DOWN
	INPUT_KEY.LEFT
	INPUT_KEY.RIGHT
	INPUT_KEY.SQUARE
	INPUT_KEY.CIRCLE
	INPUT_KEY.CROSS
	INPUT_KEY.TRIANGLE
	INPUT_KEY.LTRIGGER
	INPUT_KEY.RTRIGGER
	INPUT_KEY.HOLD
	INPUT_KEY.HOME
	INPUT_KEY.START
	INPUT_KEY.SELECT
	INPUT_KEY.NOTE

INSTALL

Place the InputManager.lua file in the same directory as your script.lua file. 

Add: 

dofile("./InputManager.lua")

somewhere near the top of your script


FUNCTIONS

void InputManager:register( { inputEvents }, { inputKeys }, eventCallback)

Register a callback handler to a group of events and a group of input keys. The first two
parameters (events and keys) do not need to be tables, they can also just be single values.

IMPORTANT - The eventCallback function MUST have the signature of void eventCallback(event, key)

EXAMPLE 

function upHandler(key, event)
   if (event == INPUT_EVENT.PRESS)
   then
      eventStr = "Pressed"
   else
      eventStr = "Released"
   end
   
   print("Up " .. eventStr)
end

InputManager:register( { INPUT_EVENT.PRESS, INPUT_EVENT.RELEASE }, INPUT_KEY.UP, upHandler )

This will register the single up handler function with both a press and release event on
the up button. Something like this would also be okay

function symbolHandler(event, key)
   
   if (key == INPUT_KEY.CROSS) then keyStr = "X"
   elseif (key == INPUT_KEY.TRIANGLE) then keyStr = "/\\" 
   elseif (key == INPUT_KEY.SQUARE) then keyStr = "[]" 
   elseif (key == INPUT_KEY.CIRCLE) then keyStr = "O" 
   else keyStr = "unknown" end
   
   print(keyStr)
   
end

InputManager:register( INPUT_EVENT.PRESS, {INPUT_KEY.SQUARE, INPUT_KEY.CIRCLE, 
		       INPUT_KEY.CROSS, INPUT_KEY.TRIANGLE}, symbolHandler)

*********************

void InputManager:deregister( { inputEvents }, { inputKeys } )

This will remove handlers from specified keys and events. Much like register, inputEvents
and inputKeys can be both tables or single values

EXAMPLE

InputManager:deregister( { INPUT_EVENT.PRESS, INPUT_EVENT.RELEASE }, INPUT_KEY.UP)

*********************

bool InputManager:isPressed(inputKey)

This will check if a key is currently pressed on the PSP.

EXAMPLE

if (InputManager:isPressed(INPUT_KEY.LTRIGGER)) 
then
	-- do some stuff
end

*********************

void InputManager:process()

This needs to be added to the main loop. With out it, nothing will be driving the input
manager

EXAMPLE

while (true) do
      processObjects() -- do whatever stuff your lua app is doing
      InputManager:process() -- process the input
end
I appreciate any feedback, I'd like to get a nice interface that most everyone is happy with. I'm still tossing up if I should allow for multiple handlers registered to a single event, at the moment there can be only one
See ya on the chronostream, time jockey!
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

I wrote a script for generating nightly builds. It builds the latest sources from the repository and makes a nice package with readme and install instructions. Download the latest nightly build

Snuffle: Great! I was going to write something similar myself, so thanks :P I'll look at it tomorrow when I'm less tired...
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Now Lua Player has its own domain: http://www.luaplayer.org/. You can download the new version 0.7. Should be nearly the same like Nevyn's nightly build, but with source code included (perhaps we should add a Makefile target for a release-folder, where anything is copied for a release, but without source, which can be obtained by SVN).
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Shine wrote:Now Lua Player has its own domain: http://www.luaplayer.org/. You can download the new version 0.7. Should be nearly the same like Nevyn's nightly build, but with source code included (perhaps we should add a Makefile target for a release-folder, where anything is copied for a release, but without source, which can be obtained by SVN).
Woah! Cool! :)

I totally agree with the release part. I imagine that those who download LuaPlayer does it either to play LuaPlayer apps, or write Lua apps. Neither of those targets need the C sources for LuaPlayer. If one is proficient enough to code in C, one is probably proficient enough to obtain the sources via svn. This is the rationale behind the packaging of my nightly build. I really suck at makefiles, but you're welcome to check out my nightly build shell script at ncoder.nevyn.nu/luaplayer-nightly.sh .
gabriel
Posts: 5
Joined: Thu Aug 11, 2005 8:33 am

Lua make error

Post by gabriel »

While trying to "make" Lua I get the following error:
In file included from graphics.c:2:
/usr/local/pspdev/psp/sdk/include/malloc.h:2: error: conflicting types for `malloc`


I appreciate any help/information.
DiabloTerrorGF
Posts: 64
Joined: Fri Jul 15, 2005 11:44 pm

Post by DiabloTerrorGF »

Here was my first LUA program(now works with .7), I just now added USB support so you can run it and write script.

PixelFixer

I had dead pixels and people said that one video that flashes the PSP screen with RGBBW will fix dead pixels, well it does work, but it was too big for 32 mb's so I made a LUA script of a faster thing that works about the same(Actually I wanna slow it down just a little bit... any ideas?).
VgSlag
Posts: 43
Joined: Thu Jun 30, 2005 5:36 pm

Post by VgSlag »

Nice one guys!

Shine, how much did the domain cost; do you want some money towards it?

My GFX card died Sunday night so I've had to code at work or very very slowly at home but I'll fix up the bugs in my game and add some more rooms today and Saturday.
VgSlag
Posts: 43
Joined: Thu Jun 30, 2005 5:36 pm

Post by VgSlag »

Nevyn, I've noticed the new looping on sounds doesn't work for extended periods of time.

I've got 2 sounds in my game, 1 looping and 1 not. After a while I hear the looping one stop.

The looping one always stops after I play the non looping one for the 32nd time if that helps.

A nice idea for the official release would be to enable the usb port by default on the screen that shows when you get an error and that you need to press start to restart.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

VgSlag wrote:Nice one guys!

Shine, how much did the domain cost; do you want some money towards it?
It is a dedicated server with very fast internet connection, much included traffice per month and with all domains it costs about 75 Euro per month, but I'll use it for my company, too, and I'll move my personal webpage to it, so this is no problem. Lua Player will remain for free for ever (it is BSD license, so even when I decide to take it off from the net, what I'll never want to do, it can be copied without problems to Sourceforge etc.).

But I'm not against if someone insists to send me money :-) You can use [email protected] at http://www.paypal.com/.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

VgSlag wrote:A nice idea for the official release would be to enable the usb port by default on the screen that shows when you get an error and that you need to press start to restart.
You can always enable it in your script, it should remain enabled after restarting, and calling the enable function when it is still enabled doesn't hurt.

Enabling it by default is a bad idea, because when you write from USB and later from within the script without disabling USB first (perhaps for a screenshot), the memory stick file system gets corrupted and you have to reformat it. I'll add a warning to the documentation. Reading can be done from both ends and writing from one end, only, is no problem. I didn't tried it, but it should be possible to write to a log file from PSP and displaying it on PC online with "tail -f /yourusbdrive/PSP/GAME/luaplayer/log.txt".
VgSlag
Posts: 43
Joined: Thu Jun 30, 2005 5:36 pm

Post by VgSlag »

Wicked, cheers for the warning :)
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

VgSlag wrote:Nevyn, I've noticed the new looping on sounds doesn't work for extended periods of time.

I've got 2 sounds in my game, 1 looping and 1 not. After a while I hear the looping one stop.

The looping one always stops after I play the non looping one for the 32nd time if that helps.

A nice idea for the official release would be to enable the usb port by default on the screen that shows when you get an error and that you need to press start to restart.
Yes, Mikmod has a limit of how many samples it can play simultaneously. If you play more, it'll start cutting old samples. I marked looping sounds as "Critical" to give it priority, but it doesn't seem to work... I'll have to do some testing. (This problem also implies that old voices aren't stopping correctly...)

As Shine said, enabling the USB port continuously is a very bad idea, as writing to the stick from two ways WILL corrupt it. (I'm not sure Shine's idea about tailing a log file while the PSP writes to the stick is a good idea, since the computer can write things to the stick without being explicitly told so. Perhaps I'm overly paranoid, but just using another less important memory stick is a simple precaution)

Remember, Lowser has USB disk mode on the L button, so if you have Lowser as the default app running after a crash (as is the standard configuration), you can just click L and fix the script without having to integrate disk mode into your own app. (btw, before I fixed Lowser, I accidently sent USB activation and deactivation once per frame when holding L, which /crashed/ the USB on my computer. Just a warning...)
alex_dsnews
Posts: 13
Joined: Wed Aug 03, 2005 9:48 pm

Wedgewars

Post by alex_dsnews »

LuaPlayer is brilliant, it really is. Here's another game I've done (which isn't brilliant, by a mile): Wedgewars - http://www.dcemu.co.uk/vbulletin/showthread.php?t=9124 - sorry, didn't think you could add attachments here.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Thanks for your donation VgSlag! I never thought to make some money with it, the main reason for developing it was the fun for me and for developing my own ideas more easy than with C, but I've added a donation link at the bottom of www.luaplayer.org
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Re: Wedgewars

Post by nevyn »

alex_dsnews wrote:LuaPlayer is brilliant, it really is. Here's another game I've done (which isn't brilliant, by a mile): Wedgewars - http://www.dcemu.co.uk/vbulletin/showthread.php?t=9124 - sorry, didn't think you could add attachments here.
Nice! Too bad you can't win... That, and some terrain, and it'd be absolutely great :) (if you packaged it for Lowser, you wouldn't have to have different installs for 1.0 and 1.5 :P)
alex_dsnews
Posts: 13
Joined: Wed Aug 03, 2005 9:48 pm

Post by alex_dsnews »

Lowser's great too. I tried to get ButtonMatch working with it a few days back but for some reason I couldn't get it to work. I'm too thick, I think.

I'll do a Lowser version for the next release - index.lua, right?
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

alex_dsnews wrote:Lowser's great too. I tried to get ButtonMatch working with it a few days back but for some reason I couldn't get it to work. I'm too thick, I think.

I'll do a Lowser version for the next release - index.lua, right?
Yep, index.lua, and making it quittable. Having an icon.png in the folder will give you a nice icon in the browser, too :)

What problems did you have? It /is/ entirely possible that I've done something wrong... ('Cause you're not stupid.)
alex_dsnews
Posts: 13
Joined: Wed Aug 03, 2005 9:48 pm

Post by alex_dsnews »

Nope, nothing you've done. It was when Shine updated all the graphics functions, and ButtonMatch was done so badly I just couldn't patch it up to get it up to date with the new functions. Entirely my fault.

I got a cute icon though.

How do you make it quittable?
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

alex_dsnews wrote:How do you make it quittable?
Just make sure the end of the file can be reached. If you have a main app loop, breaking out of it will probably do the trick.
VgSlag
Posts: 43
Joined: Thu Jun 30, 2005 5:36 pm

Post by VgSlag »

nevyn wrote:
VgSlag wrote:Nevyn, I've noticed the new looping on sounds doesn't work for extended periods of time.

I've got 2 sounds in my game, 1 looping and 1 not. After a while I hear the looping one stop.

The looping one always stops after I play the non looping one for the 32nd time if that helps.

A nice idea for the official release would be to enable the usb port by default on the screen that shows when you get an error and that you need to press start to restart.
Yes, Mikmod has a limit of how many samples it can play simultaneously. If you play more, it'll start cutting old samples. I marked looping sounds as "Critical" to give it priority, but it doesn't seem to work... I'll have to do some testing. (This problem also implies that old voices aren't stopping correctly...)

As Shine said, enabling the USB port continuously is a very bad idea, as writing to the stick from two ways WILL corrupt it. (I'm not sure Shine's idea about tailing a log file while the PSP writes to the stick is a good idea, since the computer can write things to the stick without being explicitly told so. Perhaps I'm overly paranoid, but just using another less important memory stick is a simple precaution)

Remember, Lowser has USB disk mode on the L button, so if you have Lowser as the default app running after a crash (as is the standard configuration), you can just click L and fix the script without having to integrate disk mode into your own app. (btw, before I fixed Lowser, I accidently sent USB activation and deactivation once per frame when holding L, which /crashed/ the USB on my computer. Just a warning...)
Nev, I thought this might be my fault as I wasn't assigning the sound to a voice, I was just doing:

Code: Select all

sound_jump:play()
But even when changing it to:

Code: Select all

sound_jump_playing = sound_jump:play()
I still get teh same problem.

Shine, no prob, glad to help.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

nevyn wrote:I'm not sure Shine's idea about tailing a log file while the PSP writes to the stick is a good idea, since the computer can write things to the stick without being explicitly told so.
With Unix you can mount the filesystem read-only, but for Windows I don't know when it wants to write to disk, so using a second memory stick for developing may be a good idea (I do this, too, to avoid losing my Ridge Racer and Mercury savegames :-)
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

http://haggar.pocketheaven.com/ <- Dr. Mario PSP 0.2

Ye, now with both normal horizontal and vertical mode.

(The vertical screen print was too slow for this one, so I had to use something else that's not so pretty)
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

I made a list of known luaplayer apps and games over at http://ncoder.nevyn.nu/luaplayer/01%20Known%20Apps%20and%20Games.html

If something is missing from the list, mail me at [email protected]
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

DiabloTerrorGF wrote:Here was my first LUA program(now works with .7), I just now added USB support so you can run it and write script.

PixelFixer

I had dead pixels and people said that one video that flashes the PSP screen with RGBBW will fix dead pixels, well it does work, but it was too big for 32 mb's so I made a LUA script of a faster thing that works about the same(Actually I wanna slow it down just a little bit... any ideas?).
http://haggar.pocketheaven.com/PixelFixer.zip <- I updated your pixelfixer. No need for backgroundX.png files any more. And to slow it down, just increase the delay value I added. Oh... and I hope you don't mind that I updated the code.
Last edited by MikeHaggar on Fri Aug 12, 2005 2:50 am, edited 1 time in total.
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

nevyn wrote:I made a list of known luaplayer apps and games over at http://ncoder.nevyn.nu/luaplayer/01%20Known%20Apps%20and%20Games.html

If something is missing from the list, mail me at [email protected]
You forgot ButtonMatch by Alex_dsnews/Alex Carroll
Last edited by MikeHaggar on Fri Aug 12, 2005 2:38 am, edited 1 time in total.
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

MikeHaggar wrote:
nevyn wrote:I made a list of known luaplayer apps and games over at http://ncoder.nevyn.nu/luaplayer/01%20Known%20Apps%20and%20Games.html

If something is missing from the list, mail me at [email protected]
You forgot ButtonMatch by Alex_ds/Alex Carroll
I haven't seen that one, what's the URL?
Post Reply