Pölygamy: a collection of LÖVE helper libraries

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Elvashi
Prole
Posts: 45
Joined: Sat Jul 04, 2009 9:17 am
Location: Australia

Re: Pölygamy: a collection of LÖVE helper libraries

Post by Elvashi »

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
User avatar
pygy
Citizen
Posts: 98
Joined: Mon Jan 25, 2010 4:06 pm

Re: Pölygamy: a collection of LÖVE helper libraries

Post by pygy »

Back to the topic, I'm currently working on Unicode support, patterns and multiple assignments.

Here's an example :

Code: Select all

Polygamy.keyboard.add("calculator", {
	[ { "+", "-", "*" "/", ".", "return", "c" "%d" } ] = function(k) calculator.send(k) end
})
And a basic Xwing clone could see it's input written like this:

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
})
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.
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.
User avatar
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

Post by Robin »

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.
User avatar
pygy
Citizen
Posts: 98
Joined: Mon Jan 25, 2010 4:06 pm

Re: Pölygamy: a collection of LÖVE helper libraries

Post by pygy »

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.
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.
User avatar
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

Post by Robin »

Oh, that's awesome.

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.
User avatar
pygy
Citizen
Posts: 98
Joined: Mon Jan 25, 2010 4:06 pm

Re: Pölygamy: a collection of LÖVE helper libraries

Post by pygy »

You could do

Code: Select all

[ { "[+-*.c/]", "return", "%d" } ] = calculator.send
Your example would blindly assign the r, e, t, u, r, and n keys to the same function.
Hermaphroditism is not a crime. -- LSB Superstar

All code published with this account is licensed under the Romantic WTF public license unless otherwise stated.
User avatar
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

Post by Robin »

pygy wrote:Your example would blindly assign the r, e, t, u, r, and n keys to the same function.
Woops :oops:
Help us help you: attach a .love.
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: Pölygamy: a collection of LÖVE helper libraries

Post by mikembley »

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 :ultraglee:
Geti
Party member
Posts: 112
Joined: Tue Oct 20, 2009 6:38 am

Re: Pölygamy: a collection of LÖVE helper libraries

Post by Geti »

Robin wrote:The whole point of Lua is that you don't have to compile it to make it work.
I know, i just find it nicer to have compiled libs but i'm not going to push the issue :P
This lib keeps getting better and better though, keep it up :D
User avatar
pygy
Citizen
Posts: 98
Joined: Mon Jan 25, 2010 4:06 pm

Re: Pölygamy: a collection of LÖVE helper libraries

Post by pygy »

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 ;))

Code: Select all

Polygamy.keyboard.add("function keys",{
	[ "[f1-f5]" ]=function(key,row,column,unicode) engine.throttle(column) end
}
v0.3.1 (2010/02/03)
  • First working version published :megagrin:.
  • [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.
[/size]


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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 1 guest