Is this possible to make gui_script parameter?


I’m working on tutorial and doing separated gui files for different tutorial steps.
Each gui has own script some scripts reusable and i need a parameter to define some logic and reuse one script in several gui files.


One way of doing this would be to send a message with some initialisation data from your main script file when the game starts. I do that in my game to initialise everything with the current level data and to control the order in which gui objects acquire input.


yeah. i understand that i can store settings in collection, but i thought to define everything just in gui files.


I found one temporary solution how to make parameters in GUI files

  1. need to create text box and add json data there
  2. in gui_script decode this parameter as this self.config = json.decode(gui.get_text(gui.get_node("config")))

Just one question here will engine create mesh for text which has alpha = 0 or if text bounding box is out of the screen (rendering).


I guess script properties are what you need:

Just add a line like this for each parameter you need at the top of your script:“parameter_name”, parameter_value)

The gui editor now generates input fields for you to configure your script.

In the script itself you can access your parameters via


yeah. it works with game objects. but in my case it’s a gui_script and if you will try to use it you will get this error

level1_1step.gui_script:9: can only be called outside the functions.


You can never use anything from the go.* namespace in a .gui_script and vice versa. It will not work to put in a .gui_script.


True, i somehow forgot that little detail between reading the post in the morning and answering it in the evening… :flushed:


This sounds like a really hackish thing to do! Is it really that important that you are able to enter some configuration values from within the editor?


do you have any another ideas how to make gui_script flexible and reusable?
Sure it’s possible to write another game object script but it will just add one more level of abstraction. isn’t it?


Is it an option to put the reusable parts into a lua module and have separate gui_scripts that use (and configure) that module?


Do you have an example of a gui_script that you’d like to reuse? I would imagine that most gui scenes in a game have very few similarities and that gui_script reuse isn’t really feasible. One place where it might be useful is for different kinds of popups, but in that case I’d pass configuration values when I post a “show” message to the popup.


Ok. here is my structure of the project.
I have separated collection for every level in the game. I do this to make possible to change background and make layout manually

board is reusable collection (actually it’s main game logic)
camera is the script which post to the renderer information about camera size and position
tutorial_popup is a game object where i actually attach all my tutorial popups. Each one is a separated gui file with the same script
fields_layout is just a cosmetic element (board tiles and background)

And here is my tutorial step gui scene is

Main thing here is the hole and which is inverted clipper for the gray shade.
Another elements here is a pointer_from and pointer_to, i use this positions to animate pointer (hand) movement.
stripe, left and right parts is a bottom info elements which show info to users.

So. each tutorial steps is almost the same, i need just to change hole position and info boxes. animation and another parts is the same. difference only is on which step do i need to show these popups.

Also i need to mention that in tutorial steps i need to lock user input to specific cells of the board. I’m doing this in the level config which is a json file and it looks like this

  "move_locks" : {
    "1": {
      "from": [5,4],
      "to"  : [5,3]
    "2": {
      "from": [3,4],
      "to" : [4,4]
    "3": {
      "from": [3,3],
      "to" : [4,3]

so if board see that it’s a step number 3 it will look user input to cell[3,3] and will allow move only to cell [4,3]

On gui side in config node (that text node) which i use, i specify following text value {"turn_number": 3} Later i also plan to add another values like show_shade or not and maybe something else. in script i use this code self.config = json.decode(gui.get_text(gui.get_node("config")))

ok and here is there gui_script file content which handle it

  1. Because all script appeared immediately with level, i need to disable all ui elements
  2. In update cycle i listen board status and if turn_number == turn_number from config i show and animate elements
    if self.data_appeared == false and BoardData.turn_number == self.config.turn_number then
      self.initial_timer = (self.initial_timer or 0) + dt
      if self.initial_timer > INITIAL_TIMEOUT_BEFORE_APPEAR then
        self.data_appeared = true
  1. finally from the same module which indicate board status i listen if target_cell (the cell where selected dice is moved) is not null and self destroy this component. i do that in the same update cycle
    if self.data_appeared and BoardData.target_cell and not self.destroy_in_progress then
      print("im here", self.config.turn_number)

full script is available here

Pipler + DragonKid - puzzle games