Values and function calls

I have the following structure:

[GUI Script]

Establish a table called GuiNodes that will hold node data and some meta-data about each node created…. This table is declared at the top and isn't typed local. 

Loads a library of function calls
	e.g. function drawbox(v1,v2,v3…)
	e.g. function draw text(v1,v2,v3…)

Init…
Does some stuff in init eventually including…

	1. Place a box gui object using a function call to the library drawbox()
	2. Place a text gui object using a function call to the library drawtext()

Both drawbox() and drawtext() at the end of their function write specific node information to unique keys in the GuiNodes table.

e.g. GuiNodes[“box1”] = node  structure

The issue I’m seeing is despite two distinct calls to two different function calls each of which builds their own unique node data when I pprint GuiNodes with the exception of the key the data in each separate key = that which was written in the second function call.

If I remove the second function call it’s clear the first node is writing properly to GuiNodes

When I add back the second function call it goes back to overwriting the first function call’s node item.

I can’t figure it out why

  • Ben

It sounds like when you call your function you’re modifying the same “node structure” table each time instead of creating a new one. It’s impossible to tell without seeing the code though. I would just post the whole gui_script here, or an example project.

1 Like

So… not 100% sure why it was doing this – because I was pretty sure I was doing a proper copy but there was a common table object causing this problem. Thanks!

1 Like