I'm using Tasty Text to create dialog windows, but I'm having some trouble with the :setSub function. Have a look:
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?
Problem with Tasty Text's setSub
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Problem with Tasty Text's setSub
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.
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Problem with Tasty Text's setSub
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.
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.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Problem with Tasty Text's setSub
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.
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)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: Bing [Bot] and 1 guest