Page 5 of 12

Re: A message system

Posted: Sat Jun 02, 2012 7:13 pm
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.

Re: A message system

Posted: Sat Jun 02, 2012 9:52 pm
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. :)

Re: A message system

Posted: Sun Jun 03, 2012 8:12 pm
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.

Re: A message system

Posted: Sun Jun 03, 2012 10:25 pm
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

Re: A message system

Posted: Sun Jun 03, 2012 11:02 pm
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

Re: A message system

Posted: Mon Jun 04, 2012 3:57 am
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.

Re: A message system

Posted: Tue Jun 05, 2012 1:35 am
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.

Re: A message system

Posted: Tue Jun 05, 2012 9:47 am
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.

Re: A message system

Posted: Tue Jun 05, 2012 10:05 am
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.

Re: A message system

Posted: Tue Jun 05, 2012 10:13 am
by Roland_Yonaba
Bad Ref Image
Lol.