Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] I'll give exact error in a sec. Doesn't lua have closures though?

[DiscordArchive] I'll give exact error in a sec. Doesn't lua have closures though?

[DiscordArchive] I'll give exact error in a sec. Doesn't lua have closures though?

rektbyfaith
Administrator
0
05-26-2023, 09:31 AM
#1
Archived author: Qux • Posted: 2023-05-26T09:31:48.195000+00:00
Original source

I'll give exact error in a sec. Doesn't lua have closures though?
rektbyfaith
05-26-2023, 09:31 AM #1

Archived author: Qux • Posted: 2023-05-26T09:31:48.195000+00:00
Original source

I'll give exact error in a sec. Doesn't lua have closures though?

rektbyfaith
Administrator
0
05-26-2023, 09:31 AM
#2
Archived author: Roboto • Posted: 2023-05-26T09:31:57.049000+00:00
Original source

```lua
function f(event, player)
local guid = player:GetGUID()
CharDBQueryAsync(qrystr, function(Q)
player = GetPlayerByGUID(guid)
end)
end
```
rektbyfaith
05-26-2023, 09:31 AM #2

Archived author: Roboto • Posted: 2023-05-26T09:31:57.049000+00:00
Original source

```lua
function f(event, player)
local guid = player:GetGUID()
CharDBQueryAsync(qrystr, function(Q)
player = GetPlayerByGUID(guid)
end)
end
```

rektbyfaith
Administrator
0
05-26-2023, 09:35 AM
#3
Archived author: Roboto • Posted: 2023-05-26T09:35:02.796000+00:00
Original source

Lua base types can be used safely in callbacks (as in numbers, strings, etc). Most classes provided by the core are garbage collected automatically however, so you have to keep an ID to fetch the object again, like in my example
rektbyfaith
05-26-2023, 09:35 AM #3

Archived author: Roboto • Posted: 2023-05-26T09:35:02.796000+00:00
Original source

Lua base types can be used safely in callbacks (as in numbers, strings, etc). Most classes provided by the core are garbage collected automatically however, so you have to keep an ID to fetch the object again, like in my example

rektbyfaith
Administrator
0
05-26-2023, 09:39 AM
#4
Archived author: Qux • Posted: 2023-05-26T09:39:19.959000+00:00
Original source

It says: got pointer to nonexisting (invalidated) object
rektbyfaith
05-26-2023, 09:39 AM #4

Archived author: Qux • Posted: 2023-05-26T09:39:19.959000+00:00
Original source

It says: got pointer to nonexisting (invalidated) object

rektbyfaith
Administrator
0
05-26-2023, 09:39 AM
#5
Archived author: Qux • Posted: 2023-05-26T09:39:48.540000+00:00
Original source

I'll try that
rektbyfaith
05-26-2023, 09:39 AM #5

Archived author: Qux • Posted: 2023-05-26T09:39:48.540000+00:00
Original source

I'll try that

rektbyfaith
Administrator
0
05-26-2023, 09:43 AM
#6
Archived author: Qux • Posted: 2023-05-26T09:43:57.519000+00:00
Original source

That works, ty
rektbyfaith
05-26-2023, 09:43 AM #6

Archived author: Qux • Posted: 2023-05-26T09:43:57.519000+00:00
Original source

That works, ty

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)