Navi - a message library (6/11 demo)

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
litearc
Citizen
Posts: 57
Joined: Thu May 17, 2012 12:40 am

Re: A message system

Post by litearc »

@Jasoco: Ah, ok, that makes sense. As a side note, I noticed you worked on your own game engine (viewtopic.php?f=5&t=888&start=350). It doesn't run when I try to open it (it seems to be a directory-related problem). I was just wondering if you were still working on it or if you had a working version. I'm really interested since I'm planning on eventually creating an RPG framework, though I won't try to create my own editors (Tiled does a great job at that).

@coffee: Currently, I'm cleaning up and commenting the code. Once that's done, I'll check for bugs, and then make it more independent following Jasoco's suggestions. I just don't want to put something up and have people pick it apart when I already know it has problems.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: A message system

Post by coffee »

litearc wrote:@coffee: Currently, I'm cleaning up and commenting the code. Once that's done, I'll check for bugs, and then make it more independent following Jasoco's suggestions. I just don't want to put something up and have people pick it apart when I already know it has problems.
That's ok. I saw you announcing/posting so many changes but didn't saw new uploads here in thread. I thought that you already were uploading it to git instead. Take your time. :)
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: A message system

Post by Ref »

Hi litearc!
Not sure the use of '|n' works the way you intended.
If '|n' is placed in the string, the resulting text box will have a line break at that point AND a subsiquent line break at the point where the line would have wraped if no '|n' had been inserted - leaving a line fragment.
tttttt|n|tttaaaaa (where the line would normally break at 9 characters)
becomes:
tttttt
ttt --<= a line fragment which should be included on next line
aaaaa
Would rather have the capability of doing:
ttttttt
ttttttt
ttttttt
The code controling line breaks are as as follows:

Code: Select all

 for i = 1, #s do
    if s:sub(i,i) == ' ' then   -- find word break for wrapping
       if si and sj and fontw(b:sub(bj,j-1)) > w then	-- there must be at least one ' ' before this
          ss = ss .. s:sub(bi,si-1) .. '|n'		-- add line break
                    bi = si+1
                    bj = sj+1
	end
    si = i
    sj = j
   end
and the additional line break is the added by the subsiquent code:

Code: Select all

elseif z == '|n' then
            b = s:sub(j,i-1)
            dx,dy = -xc,fonth
Just in case that this behavior is not what you want.
User avatar
litearc
Citizen
Posts: 57
Joined: Thu May 17, 2012 12:40 am

Re: A message system

Post by litearc »

Thanks Ref! If you add this at the top of the loop, it fixes it:

Code: Select all

        -- handle when there's already a newline
        if s:sub(i,i+1) == '|n' then
            ss = ss .. s:sub(bi,i+1)
            j = j-2
            si = i+1
            sj = j
            bi = si+1
            bj = sj+1
        end
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: A message system

Post by Ref »

I sort of figured that out but your code is much better.
Attached is my attempt to see how far I could push the existing code (definitely not an end product or attempt to steal your thunder.) :joker:
Waiting for rolling text in a box {O^O}
Thanks
Attachments
MessageBoxes.love
Just a demo!
(5.13 KiB) Downloaded 118 times
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: A message system

Post by Jasoco »

litearc wrote:@Jasoco: Ah, ok, that makes sense. As a side note, I noticed you worked on your own game engine (viewtopic.php?f=5&t=888&start=350). It doesn't run when I try to open it (it seems to be a directory-related problem). I was just wondering if you were still working on it or if you had a working version. I'm really interested since I'm planning on eventually creating an RPG framework, though I won't try to create my own editors (Tiled does a great job at that).
That particular project is on hold to be redone later.
User avatar
litearc
Citizen
Posts: 57
Joined: Thu May 17, 2012 12:40 am

Re: A message system

Post by litearc »

Hey, here is what I have currently. I added a few more features in, but I have not yet made the library independent (sorry Jasoco). I will do that in the final release. I initially wanted this to be the final release but Ref suggested to use a Canvas to display the message, which will be cleaner and possibly faster, but will require big changes to the system. So I decided to release the current canvas-free message system before making those changes.
Attachments
arc.love
(231.52 KiB) Downloaded 112 times
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: A message system

Post by Roland_Yonaba »

Holy ****! I Love it.
As in the screenies.
Keep on! Image
Also, no performance issues, I get around 320-330 fps running this.
Much Löve! :awesome:
litearc wrote:I initially wanted this to be the final release but Ref suggested to use a Canvas to display the message, which will be cleaner and possibly faster,
Whaaaaaaaaaaaaaaaaaaaat ? :ultrashocked:
Do this, and I'll shoot myself.
My graphic card doesn't support Canvas...

Optionnally, you can make two release, Canvas one, and Canvas-free one...?

Yet, code require some cleaning, mostly about the use of locals, as I mentionned before.
But I guess that'll be on the final release...

By the way, your table.print function could be minified using table.concat.
Last edited by Roland_Yonaba on Tue Jun 05, 2012 10:15 am, edited 1 time in total.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: A message system

Post by coffee »

litearc wrote:Hey, here is what I have currently. I added a few more features in, but I have not yet made the library independent (sorry Jasoco). I will do that in the final release. I initially wanted this to be the final release but Ref suggested to use a Canvas to display the message, which will be cleaner and possibly faster, but will require big changes to the system. So I decided to release the current canvas-free message system before making those changes.
I'm a bit incredulous. I think you going then in the wrong direction. Even that my computer support it, there is still some other people machines that don't support that. So I as a "coder" think that wouldn't be wise/safe use in a project of mine a 3rd party-library that would require use canvas. Honestly I don't see a technical necessity in your project for use that.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: A message system

Post by Roland_Yonaba »

Bad Ref Image
Lol.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests