# NewTextFile behavoir simulator vs device

**URL:** <https://forums.solar2d.com/t/newtextfile-behavoir-simulator-vs-device/150693>\
**Category:** Native builds\
**Created:** [December 9, 2019, 2:30pm UTC](https://forums.solar2d.com/t/newtextfile-behavoir-simulator-vs-device/150693 "2019-12-09T14:30:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nacho.gbm91](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/3da27b/32.png) [@nacho.gbm91](https://forums.solar2d.com/u/nacho.gbm91)\
**Post date:** [December 9, 2019, 2:30pm UTC](https://forums.solar2d.com/t/newtextfile-behavoir-simulator-vs-device/150693/1 "2019-12-09T14:30:38Z")

</div>

Hi,

I have developed my first game in corona simulator. I am wondering why the newtextfile object has different behavoir during the simulation than during device execution.

The code has a newtextfile to indicate the number of players. I want this box to have a default value, so:

```
NumPlayersField = native.newTextField(display.contentCenterX+100, display.contentCenterY+10, 35, 35 ) NumPlayersField.inputType = "number"&nbsp; --Default value NumPlayersField.text = "4" NumPlayers=tonumber(NumPlayersField.text) composer.setVariable("NumPlayers",NumPlayers)

```

NumPlayers is the local varible that store this default value (“4”) and the next scene reads this value:

```
NumPlayers=composer.getVariable("NumPlayers")

```

During the simulation, the value of this variable is filled with this default value but not during the execution in the device. The game crashes because the next scene has a for loop that depends on this value NumPlayers and this variable is empty.&nbsp;

NOTE: I have also tried this with NumPlayers as global variable instead of local.&nbsp;

---

<div class="post-metadata">

**Author:** ![sporkfin](https://forums.solar2d.com/user_avatar/forums.solar2d.com/sporkfin/32/30_2.png) [@sporkfin](https://forums.solar2d.com/u/sporkfin)\
**Post date:** [December 9, 2019, 3:32pm UTC](https://forums.solar2d.com/t/newtextfile-behavoir-simulator-vs-device/150693/2 "2019-12-09T15:32:17Z")

</div>

Hi Nacho,&nbsp;

Please use the “\<\>” buttons in the tool bar to format your code.&nbsp; Many people won’t spend time looking at it if it is not formatted.
