Im running simmilar code in each script of my game objects in order to collect data on the size and scale.
local _, window_height , _= window.get_size()
local sprite_height = go.get("shep#shep_sprite", "size.y")
local sprite_yscale = go.get("shep#shep_sprite", "scale.y")
local go_yscale = go.get_scale().y
....
do_sth()
I want to define a global funcion collect_data(game_object)
, which will return window_height, sprite_height_sprite_yscale, go_yscale
. I guess the code would look like
function collect_data(go)
local _, window_height , _= window.get_size()
local sprite_height = go.get("shep#shep_sprite", "size.y")
local sprite_yscale = go.get("shep#shep_sprite", "scale.y")
local go_yscale = go.get_scale().y
end
Where can I oput this definition, so I can use the function in each of my scripts, instead of writting the same code over and over again?