[Library] LövelyMoon v2

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [Library] LövelyMoon

Post by D0NM »

There is an error in menuState.lua example file due to the new LOVE 0.10

Code: Select all

if key == " " then
should be replaced with

Code: Select all

if key == "space" then
thanks for the lib, I'm going to use it.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [Library] LövelyMoon

Post by Davidobot »

D0NM wrote:There is an error in menuState.lua example file due to the new LOVE 0.10

Code: Select all

if key == " " then
should be replaced with

Code: Select all

if key == "space" then
thanks for the lib, I'm going to use it.
Haha, thanks for pointing that out. This library is ancient, you might need to do some tweaking inside it's own code to make it do what you want, but it should still work mostly.

Thank you anyways. :awesome:
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [Library] LövelyMoon

Post by D0NM »

Actually, I did some tweaking before my message. :) It sure works with my project.
And it made my day.

The WIKI page leads to some old stuff. So blame it ))
I like LOVE2d more and more.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [Library] LövelyMoon

Post by Davidobot »

D0NM wrote:Actually, I did some tweaking before my message. :) It sure works with my project.
And it made my day.

The WIKI page leads to some old stuff. So blame it ))
I like LOVE2d more and more.
Well, I'm glad to hear that. I hope you'll enjoy using it.
And yes, the wiki page for libraries is quite old.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
bVictor7364
Prole
Posts: 4
Joined: Fri Feb 19, 2016 10:24 pm

Re: [Library] LövelyMoon

Post by bVictor7364 »

Hey, found your library. Looks good, saved me the trouble to design the states mechanism. Though it needed some tweaking.
Here's my version of it:

Changes:
  • lovelyMoon.lua & stateManager.lua are now merged in one module "lovelyMoon".
  • All "lovelyMoon.*" functions (update, draw, etc.) are moved to "lovelyMoon.events.*".
  • All the functions that were in a global scope (from stateManager) were moved to "lovelyMoon.*"
  • Simplified adding state procedure.
  • Added a "switchState(currentID, nextID)", which basically calls "disableState(id)" and then "enableState(id)".
  • Added a "lovelyMoon.new(self)" function.
  • Simplified "state:new()" function. all you have to do now is: "return lovelyMoon.new(self)"
Reference:

Code: Select all

lovelyMoon.event.update(dt)
lovelyMoon.event.draw()
lovelyMoon.event.keypressed(key, unicode)
lovelyMoon.event.keyreleased(key, unicode)
lovelyMoon.event.mousepressed(x, y, button)
lovelyMoon.event.mousereleased(x, y, button)

lovelyMoon.new(self) -- Initializes a new state; call from: function state:new()
lovelyMoon.addState(file, id) -- return state; file argument is used for require.
lovelyMoon.isStateEnabled(id) -- return bool
lovelyMoon.getState(id) -- return state
lovelyMoon.enableState(id)
lovelyMoon.disableState(id)
lovelyMoon.switchState(currentID, nextID)
lovelyMoon.toggleState(id)
lovelyMoon.destroyState(id)
Usage:
0. Place "lovelyMoon.lua" library somewhere in source folder (e.g. "/lib/lovelyMoon.lua")
1. In main.lua add a variable to require the lovelyMoon library and preferable create a table for states:

Code: Select all

lovelyMoon = require("lib.lovelyMoon")
states = {}
2. In function love.load() add states and enable first one:

Code: Select all

function love.load()
	states.menu = lovelyMoon.addState("states.menu", "menu") -- Argument 1 is file path for require
	states.game = lovelyMoon.addState("states.game", "game")
	
	lovelyMoon.enableState("menu")
end
3. Replace love event states by lovelyMoon ones:

Code: Select all

function love.update(dt)
	lovelyMoon.event.update(dt)
end

function love.draw()
	lovelyMoon.event.draw()
end

function love.keypressed(key, unicode)
	lovelyMoon.event.keypressed(key, unicode)
end

function love.keyreleased(key, unicode)
	lovelyMoon.event.keyreleased(key, unicode)
end

function love.mousepressed(x, y, button)
	lovelyMoon.event.mousepressed(x, y, button)
end

function love.mousereleased(x, y, button)
	lovelyMoon.event.mousereleased(x, y, button)
end
4. Create the state script (e.g. "/states/menu.lua"):

Code: Select all

local state = {}

function state:new()
	return lovelyMoon.new(self)
end

function state:load()
	
end

function state:close()
	
end

function state:enable()
	
end

function state:disable()
	
end

function state:update(dt)
	
end

function state:draw()
	
end

function state:keypressed(key, unicode)
	
end

function state:keyreleased(key, unicode)
	
end

function state:mousepressed(x, y, button)
	
end

function state:mousereleased(x, y, button)
	
end

return state
5.That's all. Add game code to states' functions.
---
Check the example for more info. It also includes a state template in "states" folder (the one in step 3).
P.S. Tell me if you find any bugs.
lovelyMoon.lua
(3.42 KiB) Downloaded 370 times
lovelyMoon v2 [0.10.2].love
(7.38 KiB) Downloaded 348 times
Last edited by bVictor7364 on Fri Dec 23, 2016 2:30 am, edited 1 time in total.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [Library] LövelyMoon

Post by Davidobot »

bVictor7364 wrote:...
Wow, I am blown away at the amount of work you put into this otherwise dead library!
I looked through your code - this is some major improvement. Hell, I might even use your version for my latest project. Thanks a lot for your work! It will find good use I'm sure.
Do you mind if I link your reply in the main post?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
bVictor7364
Prole
Posts: 4
Joined: Fri Feb 19, 2016 10:24 pm

Re: [Library] LövelyMoon

Post by bVictor7364 »

Davidobot wrote: Wow, I am blown away at the amount of work you put into this otherwise dead library!
I looked through your code - this is some major improvement. Hell, I might even use your version for my latest project. Thanks a lot for your work! It will find good use I'm sure.
Do you mind if I link your reply in the main post?
Thank you, I found your library very useful, but it needed some improvement. The gamestate mechanism I designed was at least uncomfortable. But your solution is pretty elegant, so it was worth reviving. And I'd be happy if you use it as a new version of your library! :)
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: [Library] LövelyMoon

Post by Davidobot »

bVictor7364 wrote: Thank you, I found your library very useful, but it needed some improvement. The gamestate mechanism I designed was at least uncomfortable. But your solution is pretty elegant, so it was worth reviving. And I'd be happy if you use it as a new version of your library! :)
Thank you! I updated the OP!
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: [Library] LövelyMoon v2

Post by yetneverdone »

Awesome! Is this still active in development?
bVictor7364
Prole
Posts: 4
Joined: Fri Feb 19, 2016 10:24 pm

Re: [Library] LövelyMoon v2

Post by bVictor7364 »

yetneverdone wrote: Tue Mar 07, 2017 5:21 pm Awesome! Is this still active in development?
Yes, I'm using it in my current project so I'll be adding stuff to it and fixing any bugs.
Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests