# \[window.get\_size\] put only ONE value in variable/table

**URL:** <https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346>\
**Category:** Questions\
**Created:** [June 26, 2024, 4:55pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346 "2024-06-26T16:55:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vampiloup](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vampiloup/32/34713_2.png) [@Vampiloup](https://forum.defold.com/u/Vampiloup)\
**Post date:** [June 26, 2024, 4:55pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346/1 "2024-06-26T16:55:30Z")

</div>

Hi,

Those two calls on window.get\_size() :

```lua
	pprint (window.get_size())
	screen_game2 = {}
	local screen_game2 = window.get_size()
	pprint (screen_game2)

```

Give me two different answers : Calling directly the function give me the good (X and Y sizes), but puting the function result in a table (or a simple variable : no change) give only the first answer. Like that :

```lua
DEBUG:SCRIPT: 1920,
1080
DEBUG:SCRIPT: 1920

```

What gives ?

My goal is, with the use of the update function from my cursor script, to have the master gui box always in the middle of the window.

Edit : Spelling

---

<div class="post-metadata">

**Author:** ![Chung\_Xa](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/chung_xa/32/34470_2.png) [@Chung\_Xa](https://forum.defold.com/u/Chung_Xa)\
**Post date:** [June 26, 2024, 5:00pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346/2 "2024-06-26T17:00:47Z")

</div>

`local width, height = window.get_size()`

Or maybe this works `local screen_game2 = table.pack(window.get_size())`

---

<div class="post-metadata">

**Author:** ![Potota](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/potota/32/33404_2.png) [@Potota](https://forum.defold.com/u/Potota)\
**Post date:** [June 26, 2024, 5:08pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346/3 "2024-06-26T17:08:38Z")

</div>

> [@Chung\_Xa](#):
>
> `local screen_game2 = table.pack(window.get_size())`

`local screen_game2 = { window.get_size() }`

---

<div class="post-metadata">

**Author:** ![Vampiloup](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vampiloup/32/34713_2.png) [@Vampiloup](https://forum.defold.com/u/Vampiloup)\
**Post date:** [June 26, 2024, 5:09pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346/4 "2024-06-26T17:09:55Z")

</div>

Aaaahhh… That’s how it’s work. I though those functions give back a table…  
Okay, first solution works well, thank you

---

<div class="post-metadata">

**Author:** ![Vampiloup](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vampiloup/32/34713_2.png) [@Vampiloup](https://forum.defold.com/u/Vampiloup)\
**Post date:** [June 26, 2024, 5:11pm UTC](https://forum.defold.com/t/window-get-size-put-only-one-value-in-variable-table/77346/5 "2024-06-26T17:11:05Z")

</div>

Popota’s one works well too. Thank you.
