[DiscordArchive] In C++ you can pass a variable into a function using & which will allow the variable to change in th
[DiscordArchive] In C++ you can pass a variable into a function using & which will allow the variable to change in th
Archived author: Peacy • Posted: 2022-03-07T00:59:55.857000+00:00
Original source
In C++ you can pass a variable into a function using & which will allow the variable to change in the function without you having to return the data. Is there a & equivalent to lua?
Archived author: Vlad • Posted: 2022-03-07T01:04:03.896000+00:00
Original source
he should be baanned tbh
Archived author: tester • Posted: 2022-03-07T01:10:18.521000+00:00
Original source
There are no pointers in lua. Iirc tables threads and coroutines should be the only thing passed by reference rather than a copied value
Archived author: tester • Posted: 2022-03-07T01:10:57.406000+00:00
Original source
Ex passing table t and setting t[2] modified t from the global scope not just in that function
Archived author: Peacy • Posted: 2022-03-07T01:29:32.408000+00:00
Original source
There is a function in the wow api called ```lua
GetInventoryItemsForSlot(slot[,table])
```
The documentation says:
```
Returns a table (and populates one if passed as second parameter) of base item id's indexed by numerical locations.
```
In the code it looks like blizzard does something like this:
```lua
local table = {};
GetInventoryItemsForSlot(i, table);
```
When printing the values of the table after the code above, it's populated with bunch of data. If I wanted to make a function that worked similarly, would you have any idea about how one would go about doing that?
Archived author: tester • Posted: 2022-03-07T01:32:21.317000+00:00
Original source
Pass the table as a param. Run the function. Modify the table normally inside. Table is now filled.
Archived author: tester • Posted: 2022-03-07T01:32:46.626000+00:00
Original source
Tables are reference passed. Any changes in function are also on the outside table.