Psprint lua edition (with trainer wip)

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

Moderators: Shine, Insert_witty_name

Post Reply
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Psprint lua edition (with trainer wip)

Post by Arwin »

EDIT: I have now completed porting p-sprint to lua (see http://forums.ps2dev.org/viewtopic.php?t=2913 for more info on the c version of p-sprint )

Image

Here you can download the latest version:

http://www.niwra.nl/psp/p-sprint-lua/psprintlua.rar

This contains the following files:
http://www.niwra.nl/psp/p-sprint-lua/psprint.lc
http://www.niwra.nl/psp/p-sprint-lua/index.lua

The psprint.lc is a lua include file for easy use.

The index.lua is an example of how to use the include file to read p-sprint like text input.

(It's my first lua program and (thus obviously) the first time I made an include file - things may therefore look very messy, but at least it works; input is appreciated;) )

I will post my process here as I did in my p-sprint thread, and input is more than welcome.

Done:
- keychars
- keycodes
- keynames
- keygroups
- modifiers
- key repeat
- make into lua include

Still to do:
- trainer
- the wrapper functions for readex (e.g. the blocking calls like getChar)
- allow user-configuration of keymaps (all six available ones)
Last edited by Arwin on Tue Jan 24, 2006 1:36 am, edited 4 times in total.
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Ok, finally got round to a bit of coding. Still trying to get a grip on this Lua thing, but the very basics at least seem to work. I'm stuck a bit now figuring out how to do a bitwise OR in Lua, but we'll figure it out eventually I'm sure. ;)

Here's a link to the very early stuff, just the first group, basic typing, no training yet, not even backspace or a cursor.

EDIT: link removed, see first post.
Last edited by Arwin on Tue Jan 24, 2006 12:13 am, edited 1 time in total.
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

Great, I had also thought of making p-sprint for lua.

Anyway, I know lua and I believe to be a bit advanced with it. So, if you need any help, send me an AIM or PM me.

-Sam
modsyn
Posts: 28
Joined: Tue Sep 27, 2005 6:02 am

Post by modsyn »

bitwise operations came into luaplayer at version 10 and they are
and: &
or: |
xor: #

good luck learning, lua's quite fun
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Thanks for the offer, youresam.

And thanks modsyn. That # happened to be one I was looking for, and it's not that easy to find in the basic documentation of the psp version of lua.

After some playing around I felt I could do everything I did in C in Lua in about the same structure, so I rewrote to match the original.

Psprint in Lua is now already pretty much completed! :) Went smoother than I thought.

EDIT: See first post for updates, p-sprint lua is now pretty much up to speed with the C version. :)
modsyn
Posts: 28
Joined: Tue Sep 27, 2005 6:02 am

Post by modsyn »

i know, i found it while looking for a way to do bit shifting. it was on
wikipedia, the great source: http://en.wikipedia.org/wiki/Lua_for_PSP
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

modsyn wrote:i know, i found it while looking for a way to do bit shifting. it was on
wikipedia, the great source: http://en.wikipedia.org/wiki/Lua_for_PSP
Ah, there you go. Confusing that the luaplayer.org website points to a different Wiki!:

http://wiki.ps2dev.org/psp:lua_player

That should be fixed. The official integrated Wiki page is much better.
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

I have an idea for a little onscreen aid for p-sprint. The final version is going to be a bit bigger to be able to incorporate function keys and other named keys, but this is a start.

Basically you can look at this is a grid/matrix. The columns represent the left,up,right,square,triangle,circle as the first button press, and the rows represent the same for the second button press.

So the highlighted column represent the keys available to you when you have pressed the fourth button, which is the square. The highlighted letter 't' corresponds to the 5th button, which is the triangle. So square + triangle = 't'.

The keys on the diagonal (left top to right bottom) represents all buttons that can be pressed with double presses, and if I did my job right, then the most used keys should be mapped around that diagonal. It does look that way very nicely, with the diacritics at the corners. Where it deviates this was intended to be so that keys that are frequently used together are placed close to each other.

This is probably also what I'd use for a keymap manager, though I think most gain will be had by just simply adding shortcuts to frequently used keys by virtue of assigning them to Alt or Control button combinations or something similar, depending on context.

If, for instance, you'd use this in a Lua Code Editor, you could assign shortcuts to [ and ] so that Alt [ gives a (, so that you don't have to go into numbers mode to get at those. Stuff like that.

Image Image
razorrifh
Posts: 23
Joined: Sat Jun 04, 2005 2:15 am
Location: Penn State
Contact:

Post by razorrifh »

i'm not sure if this is still maintained, but i cant seem to get this to work on the current version of lua player (.20). when i try to run your code, it complains (and gives very odd error messages) about the include file, so i tried just taking the source from the include and sticking it into the index.lua, but it then it complains about expecting a 'then' but got a '&'. maybe the bitwise functions are broken in the new lua player?
Remember, for all your psp dev needs you could do worse than pspdev.org ;)
-John_K
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

That does sound like the new Lua version might be the problem. I haven't worked on it, but I'm still around and watching. If Lua changed in this respect and it was supposed to, and the code needs fixing, let me know.

In the meantime, you probably should ask this question in a Lua Engine related thread.

To verify, you could try using this with an older version of Lua, if you haven't already done so, to verify that there isn't another problem.
razorrifh
Posts: 23
Joined: Sat Jun 04, 2005 2:15 am
Location: Penn State
Contact:

Post by razorrifh »

which version of lua is this designed for? i think pspupdates still has the .15 version of lua player, unless you know another place to get the older updates.
Remember, for all your psp dev needs you could do worse than pspdev.org ;)
-John_K
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

razorrifh wrote:which version of lua is this designed for? i think pspupdates still has the .15 version of lua player, unless you know another place to get the older updates.
I'm not sure what I worked with, but I think it should at least work with 0.16.

I could see that something might have gone wrong possibly when Lua went prx compliant.

You are testing with the bare code that you downloaded from the first post, right? That should definitely work.
razorrifh
Posts: 23
Joined: Sat Jun 04, 2005 2:15 am
Location: Penn State
Contact:

Post by razorrifh »

yeah, i'm working with the two files in the rar. i want to get that working so i can learn how to integrate it into my own program(s). i'll find the .16 or any other version i can get and see how that goes.
Remember, for all your psp dev needs you could do worse than pspdev.org ;)
-John_K
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

v 0.18 and up it uses LUA v5.1 which changes the way it index's its tables. Just convert all "for key, value in table do" to "for key, value in pairs(table) do"
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

romero126 wrote:v 0.18 and up it uses LUA v5.1 which changes the way it index's its tables. Just convert all "for key, value in table do" to "for key, value in pairs(table) do"
But there aren't any for key, value in table do's in this. Are there other table related changes?
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

nope.
thats the only significant changes that would break a persons code that i see. Other than that there were a few optimizations that would add functionality. But doesnt change tables.
Post Reply