## Möan.lua - A simple messagebox system.

milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

### Möan.lua - A simple messagebox system.

I noticed there wasn't anything recent around that does this kind of thing - so I made one!

Simply;

Code: Select all

Moan.speak("Title", {"Hello world!", "It's me;--Möan.lua"})

Features:
- Multiple choice option selector
- Typing effects + UTF8 text support
- HUMP+flux camera integration
- Message box icons + title colours
- Typing skips
- Simple theming

A full example,

Code: Select all

avatar = love.graphics.newImage("image.png")
Moan.speak({"Red snake", {255,0,0}}, {"Message one", "two--and", "three..."}, {x=10, y=10, image=avatar,
onstart=function() something() end, oncomplete=function() something() end,
options={
{"Option one",  function() option1() end},
{"Option two",  function() option2() end},
{"Option three",function() option3() end}}
})

2017-10-23-132122_1366x768_scrot.png (21.54 KiB) Viewed 15611 times
The choices will be displayed on the last message in the message array.
Icons for the message box must be 380x380px - I've yet to sort out some kind of auto-scaling for this...

Anyway, here's the full documentation: https://github.com/twentytwoo/Moan.lua

Let me know what you think! Please tell me about any bugs + features you think should be added

- noImage image is now options, for text only messageboxes
- Added defMsgContainer(), an alternate way to store messages (for use with metatables for e.g.)
- Added Moan.keypressed + bug fixes, updated .love
- Added history of all messages, Moan.history.
- Added quick text pre-wrap algo
- Added option for colored title text
- Removed arbitrary 3 option limit, now "infinite"
- UI update, variable typing speeds, made HUMP camera integration optional, update .love
- Fixed recursion crashing, fixed UTF8 support
- Added sound effect on keys typed
- Added pauses, for ~dramatic effect~
- Changed syntax yet again
- Simplified function calling, updated .love
- Re-write, version 0.2.0 - now has multiple choice, execute functions on choice, choose specific icons and a better font, cleaner code base
- Cleaned up the Global namespace, a lot.
- Added UTF-8 support, thanks @FuffySifilis
- Added Moan.advanceMsg() so you can have programmable control over changing messages
Attachments
Moan.love
Last edited by milk on Wed Nov 01, 2017 5:08 am, edited 29 times in total.

FuffySifilis
Prole
Posts: 1
Joined: Wed Jul 05, 2017 10:40 am

### Re: [library] Möan.lua - Easy Messaging (like a VN)

Replace this here

Code: Select all

if typePosition <= string.len(textToPrint) then
if showingMessage then
-- Decrease timer
typeTimer = typeTimer - dt
end
if typeTimer <= 0 then
-- Timer done, we need to print a new letter:
-- Adjust position, use string.sub to get sub-string
if typeTimer <= 0 then
typeTimer = typeSpeed
typePosition = typePosition + 1
printedText = string.sub(textToPrint, 0, typePosition)
end
end
end

On this

Code: Select all

	if typePosition <= string.len(textToPrint) then
if showingMessage then
-- Decrease timer
typeTimer = typeTimer - dt
end
if typeTimer <= 0 then
-- Timer done, we need to print a new letter:
-- Adjust position, use string.sub to get sub-string
if typeTimer <= 0 then
typeTimer = typeSpeed
typePosition = typePosition + 1
local byteoffset = utf8.offset(textToPrint, typePosition)
if byteoffset then
printedText = string.sub(textToPrint, 0, byteoffset - 1)
end
end
end
end

To support another language

or

milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

### Re: [library] Möan.lua - Easy Messaging (like a VN)

Testing it out the UTF8 doesn't seem to work on my end - using love 0.10.2
2017-07-05-165040_1366x768_scrot.png (6.42 KiB) Viewed 16615 times
Also the icons for the messagebox have to be 380x380 px to fit properly - I'm working on trying some things to fix this...
Last edited by milk on Fri Jul 14, 2017 1:40 am, edited 1 time in total.

zorg
Party member
Posts: 2915
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: [library] Möan.lua - Easy Messaging (like a VN)

It does work, you just need to use a font that actually has the characters you want to display.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

### Re: [library] Möan.lua - Easy Messaging (like a VN)

zorg wrote:
Wed Jul 05, 2017 5:08 pm
It does work, you just need to use a font that actually has the characters you want to display.
Makes sense - I assumed we we're using the same font since they look the same, my bad. Guess I'll go set up some fallbacks now

milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

### Re: [library] Möan.lua - Easy Messaging (like a VN) with multiple choices

Currently in the process of a total rewrite to include selectable message options which can trigger functions, pauses and more

EDIT: Rewrite done, docs updated and a demo .love added

milk
Prole
Posts: 39
Joined: Sun Jul 17, 2016 7:20 pm

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

It's not dead!, I've recently had some spare time to start working on this again. Now that I'm much more comfortable with OO and LOVE I've started yet another re-write which should be done by summer time (exams are hell) - anyway, here's what I had in mind for when it's done:
2018-03-31-144227_1366x768_scrot.png (18.23 KiB) Viewed 14856 times

BukkitmanMC
Prole
Posts: 10
Joined: Sat Apr 29, 2017 4:06 am

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

This is such a useful library! is it free to use? I am planning on using it in a game, maybe with a few small modifications if it is ok for you

Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

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

This library looks really interesting. Do you remember the dialog boxes in Grandia 1?

(Scroll to 11:24)

I really liked that game, because of the changing emotion images of the characters. I'm sure this can be archived by putting more Moan.speak calls with different images. However, a dialog with n changes would cause nested functions n deep, since the next Moan.speak call needs to be placed in the oncomplete, it doesn't need? It would be great if we could pass more information for each text. I.e.:

Code: Select all

{
{ message = "Message one", image = avatar_happy }, -- table instead of string for a complexer step in the conversation
"two--and", -- this could remove the image or keep using avatar_happy
{ message = "three...", image = avatar_sad }
}

Also: Instead of passing the options into another parameter, you also could allow to specify options in the message tables itself like I would do with the changing image. The oncomplete function should pass all selected options, so I could make 3 choices and react to those after the conversation has been made. An additional parameter in the options table could even contain follow up messages. Here is a more complete example:

Code: Select all

avatar_happy = love.graphics.newImage("image_happy.png")
Moan.speak({"Red snake", {255,0,0}},
{ message = "Message one", image = avatar_happy },
"two--and",
{ message = "three...", image = avatar_sad, options = {
{"Option one",  function() option1() end},
{"Option two",  function() option2() end, { message = "You selected Option 2.", image = avatar_happy }}, -- we could keep nesting here
{"Option three",function() option3() end}}
}
}, {x=10, y=10, image=avatar, onstart=function() something() end, oncomplete=function(selectedOptions) something() end,
options={
{"End option one",  function() endoption1() end},
{"End option two",  function() endoption2() end},
{"End option three",function() endoption3() end}}
})

Also, I'm a huge fan of this kind of dialog boxes:

Sadly it might feel playful, but lacks the expressions of images. I always was hoping to find something like this with images in a game. Maybe you are interested in enhancing this lib to allow such a speech bubble mode to display image and text in a bubble that arrows to a specific point on the screen. This example also shows how important customisation is. Can your dialog boxes be customised by using textures?

Just my open thoughts.
Anyway, keep up that good work.

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

jdoolin
Prole
Posts: 28
Joined: Sat Nov 18, 2017 7:40 pm

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

modiX wrote:
Tue Apr 03, 2018 10:50 am
This library looks really interesting. Do you remember the dialog boxes in Grandia 1?
I really liked that game, because of the changing emotion images of the characters. I'm sure this can be archived by putting more Moan.speak calls with different images.

Also, I'm a huge fan of this kind of dialog boxes. [Comic style with a tail indicating the speaker]
It just so happens that I'm currently working on a Dialogue Panel library specifically meant to work with Möan.lua. To put it simply, I plan to use Möan's excellent dialogue message system combined with my dialogue panels.

There shouldn't be a problem with supporting multiple character avatars for various emotions, and I'm now working on indicator tails like the Final Fantasy IX screenshot. Looks like I'm going to need to research Stencils. Though this may not work with one of the panel styles I'm supporting.

Currently I support three types of panels:

RectPanels are drawn using Love2D's rectangles, have optional borders (and border colors), rounded corners and drop shadow (with shadow color).

TilePanels are drawn with a nine-box (3x3) image that defines the corners and sides of the panel. At the moment, Quad bleeding is making it a pain in the arse to scale the center image with a linear filter, so it requires that it be a separate image. The actual border sides are scaled without interpolation. I also still need the option to fill it with a simple rectangle instead of a scaled image, or a tiled image. So that's on the TODO list.

FancyPanels make use of RPG Maker's Windowskin format, which is a single tile atlas that defines panel borders, backgrounds, cursors, and more-text indicators.

I'm also supporting the construction of complex menu layouts composed of multiple panels. At the moment you can create Fixed size panels and Fitted panels that will size themselves according to their text. I also have handy placement/alignment functions, such as "top left" and "center screen".

Every panel has an optional Transition (enter the window from the sides, fade-in, zoom/scale-in, wipe, splits). Fonts are customizable, you can apply drop shadow to text.

Here are some screenshots:

TilePanel, fixed size, center screen:
Dialog-1523221125.png (19.53 KiB) Viewed 14531 times
Fitted RectPanel with rounded corners, drop shadow and a border, aligned top center
Dialog-1523221061.png (8.32 KiB) Viewed 14531 times
Fitted FancyPanel, top right
Dialog-1523221037.png (15.14 KiB) Viewed 14531 times

### Who is online

Users browsing this forum: No registered users and 23 guests