Forums WoW Modding Support Archives WoWModding Support Archives [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

[DiscordArchive] That would work if the code is in the same file or w/e since the local was defined outside of the fu

rektbyfaith
Administrator
0
03-07-2022, 03:35 AM
#1
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?
rektbyfaith
03-07-2022, 03:35 AM #1

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?

rektbyfaith
Administrator
0
03-07-2022, 03:36 AM
#2
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)
rektbyfaith
03-07-2022, 03:36 AM #2

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)

rektbyfaith
Administrator
0
03-07-2022, 04:12 AM
#3
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.
rektbyfaith
03-07-2022, 04:12 AM #3

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.

rektbyfaith
Administrator
0
03-07-2022, 04:13 AM
#4
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
```
rektbyfaith
03-07-2022, 04:13 AM #4

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
```

rektbyfaith
Administrator
0
03-07-2022, 04:13 AM
#5
Archived author: tester • Posted: 2022-03-07T04:13:32.587000+00:00
Original source

lua may think a reassignment wants a copy
rektbyfaith
03-07-2022, 04:13 AM #5

Archived author: tester • Posted: 2022-03-07T04:13:32.587000+00:00
Original source

lua may think a reassignment wants a copy

rektbyfaith
Administrator
0
03-07-2022, 04:13 AM
#6
Archived author: tester • Posted: 2022-03-07T04:13:47.361000+00:00
Original source

rather than modifying the object
rektbyfaith
03-07-2022, 04:13 AM #6

Archived author: tester • Posted: 2022-03-07T04:13:47.361000+00:00
Original source

rather than modifying the object

rektbyfaith
Administrator
0
03-07-2022, 06:11 AM
#7
Archived author: Lantic • Posted: 2022-03-07T06:11:41.565000+00:00
Original source

Not really that would bring way more drama
rektbyfaith
03-07-2022, 06:11 AM #7

Archived author: Lantic • Posted: 2022-03-07T06:11:41.565000+00:00
Original source

Not really that would bring way more drama

Recently Browsing
 
Recently Browsing