I tried increasing max character in my game.project file to prevent an “Out of text-render buffer” error. When I did it, the number converted into a float in the editor. Console outputs
WARNING:DLIB: Unable to convert ‘64000.0’ to int
and the buffer fails to increase. Trying to delete the .0 doesn’t work. It comes back when you click out of the box. Is this a bug?
And it is! I’m working a text-heavy game controlled by a UI. I hit the limit of the event passing system so I’m trying other ways of getting lots of text rendered.
Are you actually going to render all of that text at the same time or could you re-use text fields?
And what did you mean by hitting limits in the event passing system (I suppose you mean msg.post())? There are other ways to share text between scripts, besides posting the whole thing. One option would be to store the text in a lookup table in a Lua module and only post the key that maps to the text in question.
I don’t know if I’ll need all that space. At first, I was going to set it that high then lower it until I hit the error again, then continue and increase it as necessary.
And yes, I hit the limit in msg.post(). A lookup table may work, though some of the stuff in these text blocks is generated on the fly. Hooray for procedural text generation. Still, the large block in question doesn’t have any of that stuff so it would be a good test case for a lookup table.
It doesn’t really matter if the text is hardcoded in a source file, read from JSON or a server or generated at run-time. As long as you store it in a Lua table and pass the keys it should all be fine. Something like this:
text_cache.lua:
-- let's start with a text cache with some predefined text
local cache = {}
cache.intro = [[Welcome to this super awesome thing
I really hope you enjoy it.
#madewithdefold]]
return cache
some.script:
local cache = require "text_cache"
function init(self)
-- let's add some more text
cache.greeting = "Hello " .. player_name
cache.some_other_long_generated_text = markov_chain()
-- let's show the long generated text in a dialog/popup
msg.post("dialog", "show", { text = "some_other_long_generated_text" })
end
dialog.gui_script:
local cache = require "text_cache"
function on_message(self, message_id, message, sender)
if message_id == hash("show") then
-- grab the text or default to the key if the text is missing
local text = cache[message.text] or message.text
gui.set_text(gui.get_node("text"), text)
end
end