Problem with Tasty Text's setSub

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Problem with Tasty Text's setSub

Post by megalukes »

I'm using Tasty Text to create dialog windows, but I'm having some trouble with the :setSub function. Have a look:
text issue.gif
text issue.gif (61.86 KiB) Viewed 3291 times
Everytime setSub goes to a new line, it draws its firt character twice (it doesn't happen in the last line for some reason). How do I solve this?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Problem with Tasty Text's setSub

Post by Positive07 »

That is a problem with tasty text, it counts the newline (\n) character when doing the substring but not when rendering. It should ignore it as a character. That is if a newline character is found it should go to the next (not newline) character.

But I haven't used nor developed the library so I can't really help you. I think you should post an issue to their issue tracker.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
PerdeT
Prole
Posts: 7
Joined: Wed Sep 21, 2016 9:23 pm

Re: Problem with Tasty Text's setSub

Post by PerdeT »

I'm facing the same problem... I got rid of the flashing character by changing the last line of function TastyText:setSub to this:
self.first,self.last = first-1,last
But it's a dirty "solution" and creates a whole lot of problems. I think I'll try to find how to at least locate the bug Positive07 mentioned.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Problem with Tasty Text's setSub

Post by Positive07 »

The problem is the _parseString function, that thing strips new line characters, trailing whitespace, tags and whatnot, when you setSub you are actually setting it to the original string, and then when it calculates the length of each chunk it doesn't add the characters it deleted (new lines, whitespace, tags).

Basically it sets self.first and self.last based on the parsed string. To parse it strips newlines and creates an array with all the chunks that make up the text (images, each line of text and everything else) and calculates the length of each chunk (but chunks don't have newline or trailing whitespaces anymore). When rendering it adds the length of the chunk until self.first is inside of the current chunk and renders it (self.first takes into consideration newlines and trailing whitespace while chunk.length does not), then it keeps drawing until chunk.length added up to be more than self.last (self.last takes into consideration newlines and trailing whitespace while chunk length does not)

This discrepancy between self.first and self.last taking into consideration newlines and trailing whitespace and chunk.length ignoring them is the error you are currently experiencing.

The solution would be to count newlines and trailing whitespace and subtracting it from self.first and self.last. I think that should be enough

Also note that markandgo library hasn't been updated in a year and a half so I would counted as deprecated and wouldn't use it in a new project.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests