[DiscordArchive] That would work if the code is in the same file or w/e since the local was defined outside of the fu
[DiscordArchive] That would work if the code is in the same file or w/e since the local was defined outside of the fu
Archived author: Peacy • Posted: 2022-03-07T03:35:47.827000+00:00
Original source
That would work if the code is in the same file or w/e since the local was defined outside of the function. However, what would you do in a situation where you have the code I linked above in a file and the function that deals with the code in another file? As far as i'm aware, modifying the table normally wouldn't effect the the local from the other file, would it?
Archived author: tester • Posted: 2022-03-07T03:36:39.003000+00:00
Original source
in theory it shouldnt matter as long as the table is global to reach that function(or possibly if the function is global and the table is local to another file should still work)
Archived author: Peacy • Posted: 2022-03-07T04:12:39.757000+00:00
Original source
```lua
-- Code in FileA.lua
local test = {};
MyFunction(test);
print (test[1]);
```
```lua
-- Code in FileB.lua
function MyFunction(test)
test = {1, 2, 3};
end
```
In this code, when I print test[1] it doesn't return 1 like it should. The test variable is local but the function is not local. Am I doing anything wrong here? From what I can tell it would appear I met the parameters that were outlined from the last few messages.
Archived author: tester • Posted: 2022-03-07T04:13:26.384000+00:00
Original source
rather than reassignment, try doing
```
test[1] = 1
test[3] = 3
test[3] = 3
```
Archived author: tester • Posted: 2022-03-07T04:13:32.587000+00:00
Original source
lua may think a reassignment wants a copy
Archived author: tester • Posted: 2022-03-07T04:13:47.361000+00:00
Original source
rather than modifying the object
Archived author: Lantic • Posted: 2022-03-07T06:11:41.565000+00:00
Original source
Not really that would bring way more drama