Defglot "Bad argumet #1 to "next" " [SOLVED]

Good afternoon, at the moment I am trying to learn how to use the defglot module, but even looking at the example project I am not able to implement the work of the module in my own code. Please help me to find my mistake.

GUI struct:
image

require "main.translations" 

function init(self)
    {...}
	local defglot = require("defglot.defglot")
	defglot.language = "en" -- if you do not define the language DefGlot will attempt to use OS lang
	defglot.language_list.en = "en" -- add one or more langauges to in use language list
	defglot.locale_data = "en" -- this is the locale data
	defglot.init() -- you must init DefGlot so that it can ensure proper setup

	defglot.set_text(gui.get_node("upgrade/text"), "UPGRADE")


image

By the way, did I understand correctly that the defglot module script should be written for each script separately ?

If you don’t use GUI templates, you have to directly point to the text node. However, that also means you would need to uniquely name all text nodes if you have multiple.

defglot.set_text(gui.get_node("text"), "UPGRADE")
1 Like

Thanks, it did indeed work, but now I’m getting another error.

image
image

{...}
	defglot.set_text(gui.get_node("up_text"), "UPGRADE")
{...}

I tested set_text even with a manually set string argument, but I’ll still share how I hooked up the lua file just in case.
image
translations.lua
image

Resolved! That’s where the mistake was:

Wrong:

{...}
	defglot.locale_data = "en" -- this is the locale data
{...}

That’s right:

	defglot.locale_data =  require("main.translations")

Important: You pass a translation file to this function, not the language of the system. t

1 Like