[DiscordArchive] oh so you can nest functions?
[DiscordArchive] oh so you can nest functions?
Archived author: jintao41 • Posted: 2022-11-04T17:22:33.361000+00:00
Original source
oh so you can nest functions?
Archived author: Honey • Posted: 2022-11-04T17:22:56.045000+00:00
Original source
Load after as in just trade their places.
Archived author: Honey • Posted: 2022-11-04T17:23:14.818000+00:00
Original source
The elegant solution which avoids many problems is the array.
Archived author: Honey • Posted: 2022-11-04T17:25:06.758000+00:00
Original source
First line would be
`local myscriptname = {}`
And from there every declaration is placed inside that array.
`function myscriptname.SwitchZone( event, player, _, _ )`
Archived author: jintao41 • Posted: 2022-11-04T17:26:04.926000+00:00
Original source
that way variables defined in one function are available to the other, but do not leave the array or touch other scripts, correct?
Archived author: Honey • Posted: 2022-11-04T17:26:26.804000+00:00
Original source
If it's local it all stays within that file
Archived author: Honey • Posted: 2022-11-04T17:26:56.164000+00:00
Original source
And yes, they're all available towards each other regardless of order.
Archived author: jintao41 • Posted: 2022-11-04T17:29:04.313000+00:00
Original source
that is very helpful, thank you. For the logic part, do you have an idea why it saves new coordinates while the player does not switch zones? Or is that because I do not bind these variables to a player, as you suggested?
Archived author: jintao41 • Posted: 2022-11-04T17:30:18.739000+00:00
Original source
Meaning, I see why I should bind these to the player anyway, but might that be the reason it is saving new coordinates?
Archived author: Honey • Posted: 2022-11-04T17:32:45.831000+00:00
Original source
Currently you have a single variable, which is assigned a new value whenever ANY player changes the map.
Define them as arrays.
```lua
PlayerX = {}
```
```lua
PlayerX[ player:GetGUIDLow() ] = player:GetX()
```