How gui node get same exact position in game object

This is not how you require a module:

local card_prop = "card/cardglue"

In my previous post I outlined how to do it:

local card_prop = require "path.to.card_prop"

I am guessing your module is called cardglue.lua and stored in a folder called card. In that case:

local card_prop = require "card.cardglue"
1 Like

still same error

so to declare in require directory is not “/” but “.”

local card_prop = "card.cardglue"

function init(self)
	msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
	card_prop.store_card_id_pos("/card/card.go")
end
local card_prop = "card.cardglue"

This is still not correct. Read his suggestions carefully :slight_smile:

1 Like

ok my bad i am typo. i am so sad about it

still nil value

function card_prop.store_card_id_pos(card_id)
	card_id_pos = go.get_position(go.get_id(card_id))
	print(card_id_pos)
end

this is my go object script

local card_prop = require "card.cardglue"

function init(self)
	msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
	card_prop.store_card_id_pos("/card/card.go")
end

this is the error

ERROR:SCRIPT: card/cardglue.lua:9: Instance (null) not found
stack traceback:
[C]:-1: in function get_position
card/cardglue.lua:9: in function store_card_id_pos
card/card_spawn.script:5: in function <card/card_spawn.script:3>

The go id doesn’t look right.

Have a look at this manual:

You don’t use “.go” when getting an id. It seems to me you are using “Path” rather than “Url”:

image

seems the autocomplete code get little mess because it’s said required path.But whatever i will change it

To be clear, it’s this part that is wrong.

yes , i am understand sir

1 Like

ok the print result is appear

DEBUG:SCRIPT: Listening for debugger on 0.0.0.0
DEBUG:SCRIPT: Debugger connected from 127.0.0.1
DEBUG:SCRIPT: vmath.vector3(58, 253, 0)

but when I using

gui.set_position(gui_node, card_id_pos)

this error is appear
ERROR:SCRIPT: card/cardglue.lua:15: bad argument #2 to ‘set_position’ (vector4 expected, got nil)
stack traceback:
[C]:-1: in function set_position
card/cardglue.lua:15: in function size
card/card.gui_script:4: in function <card/card.gui_script:3>

I assuming gui and game object vector properties is different

No, the vectors are the same.

What does print( gui_node, card_id_pos) just before line 15 output?

are you mean this

DEBUG:SCRIPT: Listening for debugger on 0.0.0.0
DEBUG:SCRIPT: Debugger connected from 127.0.0.1
ERROR:SCRIPT: card/cardglue.lua:15: bad argument #2 to ‘set_position’ (vector4 expected, got nil)
stack traceback:
[C]:-1: in function set_position
card/cardglue.lua:15: in function size
card/card.gui_script:4: in function <card/card.gui_script:3>

function card_prop.size(gui_node, card_id)
	gui_node = gui.get_node(gui_node)
	print(gui_node, card_id_pos) --I want to see the output of this
	gui.set_position(gui_node, card_id_pos)
	return gui_node, card_id
end
1 Like

DEBUG:SCRIPT: box@(133, 544, 0) nil

this print result is appear

Are you sure you are calling card_prop.store_card_id_pos() before card_prop.size()? If you are doing both in init() then the order is not guaranteed.

i am not sure because i am newbie here. You are more advanced than me. Then do you have any advice for me?

ps : I learn a lot from this case about debugging. Many thanks of that

1 Like

If you zip up the project (first delete “build” and “.internal” folders) then I can take a look.

here is the file
Mobile game.zip (203.6 KB)

many thanks about your sincerity.

Yes, it’s an order issue. If you do this in card.gui_script:

	timer.delay(0.01, false, function()
		card_prop.size("card_front", "/card")
	end)

Then this function will run after the go equivalent.

1 Like

wow it’s working . so in my case i must using timer to resolve this problem