Möan.lua - A simple messagebox system.

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

Re: Möan.lua - A simple messagebox system.

Post by milk » Sat Jun 30, 2018 3:52 pm

Moan.speak is used to insert a single message into the message queue, and therefore should only be called once per message - by putting Moan.speak into love.draw you are inserting new message every frame (which would probably cause the game to crash eventually)
Moan.update updates the library (which you forgot to add)
Moan.draw is used to draw the messages in the message queue

Hopefully this works (in LOVE 0.10.x) - untested btw.

Code: Select all

require("lovesplash/lovesplash")
local Moan = require("Moan")

state = "lovesplash"

function love.load()
  -- Insert a message into the message queue 
  -- Message shown when Moan.draw called (in menu state)
  Moan.speak("Title", {"Hello world!", "It's me;--Möan.lua"})
end

function love.draw()
  if state == "lovesplash" then
    lovesplash.draw()
  else if state == "menu" then
    Moan.draw()
  end
end

function love.update(dt)
  if state == "lovesplash" then
    lovesplash.update(dt)
    if lovesplash.done() then
      state = "menu"
      Moan.update(dt)
    end
  end
end

function love.keypressed()
  if state == "lovesplash" then
    lovesplash.stop()
  else if state == "exit" then
    love.event.quit()
  else
  end
end
end

function love.mousepressed()
  if state == "lovesplash" then
    lovesplash.stop()
  else if state == "exit" then
    love.event.quit()
  else
  end
end
end
Also I'd recommend reading the example main.lua (https://github.com/ttxi/Moan.lua/blob/master/main.lua) as it shows how to use the library and is pretty heavily commented.
I apologise in advance for how awkward the library is to use - I wrote it last year when my programming skills were pretty bad, I'm planning a rewrite in the near future for LOVE 11.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests