Pölygamy: a collection of LÖVE helper libraries
Re: Pölygamy: a collection of LÖVE helper libraries
Luac exists as a specific solution for specific problems, by and large you shouldn't ever have to actually use it, and doing so is advised against, as it negates several of Lua's advantages (both in the toolchain, and at runtime) for very little gain.
"We could make a program for doing this for you, but that is for the LÖVE IDE, planned to be released in March 2142." ~mike
Networking with UDP uLove Proposal CCG: Gangrene
Networking with UDP uLove Proposal CCG: Gangrene
Re: Pölygamy: a collection of LÖVE helper libraries
Back to the topic, I'm currently working on Unicode support, patterns and multiple assignments.
Here's an example :
And a basic Xwing clone could see it's input written like this:
I'm also thinking of adding a new constants: Polygamy.before that will catch all keys before it's sent down the road. Good for logging.
Polygamy.keybaord is actually becoming a keyboard definition DSL. I like that.
Now it's time to debug.
Next up: serialization to allow the possibility of saving the configuration.
Here's an example :
Code: Select all
Polygamy.keyboard.add("calculator", {
[ { "+", "-", "*" "/", ".", "return", "c" "%d" } ] = function(k) calculator.send(k) end
})
Code: Select all
Polygamy.keyboard.add("X-Wing",{
[ "[1-4]" ] = function(s) spaceShip.setSpeed(s+0) end,
[ "[5-8]" ] = function(w) spaceShip.setWeapon(w-4) end,
[ { [[ %arrows ]], "[WASD]"} ] = { held = function(k,dt) spaceShip.move(k,dt) end },
[" "] = {
pressed = spaceship.shoot,
held = function(k,dt) spaceShip.accumulateEnergy(dt) end,
released = spaceShip.unleashBigBlow
},
b = spaceShip.launchBomb
escape = game.quit
})
Polygamy.keybaord is actually becoming a keyboard definition DSL. I like that.
Now it's time to debug.
Next up: serialization to allow the possibility of saving the configuration.
Last edited by pygy on Fri Jan 29, 2010 5:28 pm, edited 1 time in total.
Hermaphroditism is not a crime. -- LSB Superstar
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Pölygamy: a collection of LÖVE helper libraries
If you use pattern matching, I don't think the calculator example will work. I think you should change it to this:
Code: Select all
Polygamy.keyboard.add("calculator", {
[ { "\+", "\-", "\*" "/", "\.", "return", "c" "%d"}] = function(k) calculator.send(k) end
})
Help us help you: attach a .love.
Re: Pölygamy: a collection of LÖVE helper libraries
No, I'm using custom patterns, with a hand made parser. Their syntax is based on the standard Lua one, but it's more limited and more capable at the same time. Currently %a, %d, %w, %arrows, [0-9], [a-z] and [whatever,one_key-at/a.time!including+restricted*characters] are supported, but with only one pattern per string.
The point is to make the common case easy, and to keep the code readable.
The point is to make the common case easy, and to keep the code readable.
Last edited by pygy on Fri Jan 29, 2010 5:52 pm, edited 1 time in total.
Hermaphroditism is not a crime. -- LSB Superstar
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Pölygamy: a collection of LÖVE helper libraries
Oh, that's awesome.
Would that mean that one would be able to represent the example code as:
?
(btw, I made a mistake earlier: in Lua, special characters in patterns are escaped with %, not \. I apologize to anyone I might have offended. Such as bartbes.)
Would that mean that one would be able to represent the example code as:
Code: Select all
Polygamy.keyboard.add("calculator", {
[ { "[+-*return.c/]", "%d"}] = function(k) calculator.send(k) end
})
(btw, I made a mistake earlier: in Lua, special characters in patterns are escaped with %, not \. I apologize to anyone I might have offended. Such as bartbes.)
Help us help you: attach a .love.
Re: Pölygamy: a collection of LÖVE helper libraries
You could do
Your example would blindly assign the r, e, t, u, r, and n keys to the same function.
Code: Select all
[ { "[+-*.c/]", "return", "%d" } ] = calculator.send
Hermaphroditism is not a crime. -- LSB Superstar
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Pölygamy: a collection of LÖVE helper libraries
Woopspygy wrote:Your example would blindly assign the r, e, t, u, r, and n keys to the same function.
Help us help you: attach a .love.
Re: Pölygamy: a collection of LÖVE helper libraries
I've only skimmed through all of these posts, But from what i see this seems helpful
The reason i posted is because i saw a reference to the Lost Vikings! I loved that game as a child! Required plenty of strategic skill and logic unlike all these next gen titles which are so linear and mindnumbing...
Keep up the good work
The reason i posted is because i saw a reference to the Lost Vikings! I loved that game as a child! Required plenty of strategic skill and logic unlike all these next gen titles which are so linear and mindnumbing...
Keep up the good work
Re: Pölygamy: a collection of LÖVE helper libraries
I know, i just find it nicer to have compiled libs but i'm not going to push the issueRobin wrote:The whole point of Lua is that you don't have to compile it to make it work.
This lib keeps getting better and better though, keep it up
Re: Pölygamy: a collection of LÖVE helper libraries
v 0.3.1 is online (see first post) and it works !!
The most important new features is the keyboard-based patterns expansions (see below for examples). To make this more useful, the coordinates of each keys are now passed to the bound functions along the key string and unicode number if relevant. They only work properly on US qwerty keyboards, due to a current limitation of LÖVE itself. It can still be useful if you target the subset common to qwerty,qwertz and azerty (sorry, Dvorak users )
v0.3.1 (2010/02/03)
v0.3 (2010/02/02)
Some corner cases may still be problematic, of course, but it should be usable as is for most purposes.
Have fun
The most important new features is the keyboard-based patterns expansions (see below for examples). To make this more useful, the coordinates of each keys are now passed to the bound functions along the key string and unicode number if relevant. They only work properly on US qwerty keyboards, due to a current limitation of LÖVE itself. It can still be useful if you target the subset common to qwerty,qwertz and azerty (sorry, Dvorak users )
Code: Select all
Polygamy.keyboard.add("function keys",{
[ "[f1-f5]" ]=function(key,row,column,unicode) engine.throttle(column) end
}
- First working version published .
- [q-r] => {q, w, e, r} (horizontal). -- [x-5] => {x, d, r, 5} (diagonal) -- [6-h] => {6, y, h} (vertical) -- [f1-f10] => {f1, f2, ... , f10} -- Assumes an US qwerty keyboard at the moment.
- Simplified the callbacks a bit.
- Don't use doto().replaceWith() at the moment (there's a known bug regarding inheritance preservation).
v0.3 (2010/02/02)
- /!\ Still not tested (and completely broken)
- TypeMatic (key repeat).
- Unicode.
- Track the active context (to reset options).
- Reset options on doto actions.
- Pattern matching.
- pass key coordinates to all callbacks.
- "Before" blocks.
- Extensive code documentation.
Some corner cases may still be problematic, of course, but it should be usable as is for most purposes.
Have fun
Last edited by pygy on Wed Feb 03, 2010 7:14 pm, edited 1 time in total.
Hermaphroditism is not a crime. -- LSB Superstar
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 1 guest