Quantcast When does the Game a frame forward? - ESOUI
Thread Tools Display Modes
08/08/19, 03:13 AM   #1
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
When does the Game a frame forward?

Hi Folks,

At the moment I try to build an automated action for looting. It does as follows.


On Addon Load -> Register LootInit for EVENT_LOOT_UPDATED

When Player Loots:
Unregister for EVENT_LOOT_UPDATED -> (When lootitem = false) Register SetGlobalData for EVENT_INVENTORY_SINGLE_SLOT_UPDATE
LootItembyID <- because we would fire on the Inventory Single Slot Update Event
CallBack ItemSort <- and here starts the Problem. The Game hasnt forwarded to the next frame and the data is given empty.

I also tried to build up a chain with Register Handshakes without using a for loop, but this also dont work, because I allways have to wait till the game has made the frame before I get the needed dataset.

How can I get sure, that the game has processed a frame, before I do my next action or is there a trick for parallelizing this?
  Reply With Quote
08/08/19, 03:53 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 493
Originally Posted by cOOLsp0T View Post
Hi Folks,

At the moment I try to build an automated action for looting. It does as follows.


On Addon Load -> Register LootInit for EVENT_LOOT_UPDATED

When Player Loots:
Unregister for EVENT_LOOT_UPDATED -> (When lootitem = false) Register SetGlobalData for EVENT_INVENTORY_SINGLE_SLOT_UPDATE
LootItembyID <- because we would fire on the Inventory Single Slot Update Event
CallBack ItemSort <- and here starts the Problem. The Game hasnt forwarded to the next frame and the data is given empty.

I also tried to build up a chain with Register Handshakes without using a for loop, but this also dont work, because I allways have to wait till the game has made the frame before I get the needed dataset.

How can I get sure, that the game has processed a frame, before I do my next action or is there a trick for parallelizing this?
EVENT_MANAGER:RegisterForUpdate(identifier, 0, function() EVENT_MANAGER:UnregisterForUpdate(identifier) end)
The function is called on the next frame, because the timeout of zero will be over.
identifier is a unique string. Whatever you want, but it has to be unique.
__________________
@votan73 (EU - megaserver)
  Reply With Quote
08/08/19, 06:13 AM   #3
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
hmmm.... thx that solves another problem which I got, but the given problem is still the same.

I need the bagID, slotID and stackCountChanged from INVENTORY_SINGLE_SLOT_UPDATE for my data. I really dont understand why It doesnt proceed right when the Item is getten looted, because after looting will the inventory change and about my understanding have the event to be fired, but it fires after the looting function is ended. Did I miss something?

Here is a Log of my runtime vars. As you can see, will the globals updated too late. It has to be updated right after Looted
Code:
[14:04]  cOOLsp0T's Loot Manager 1.1  Activated 
[14:04]  LootMgr: REG >>> LootInit() >>> LOOT_UPDATED
[14:04]  LootMgr: UNREG <<< LootInit() <<< LOOT_UPDATED
[14:04]  LootMgr: ID: 1
[14:04]  LootMgr: Name: Deteri^N
[14:04]  LootMgr: Amount: 1
[14:04]  LootMgr: Quality: 1
[14:04]  LootMgr: Gold: 1
[14:04]  LootMgr: Quest: false
[14:04]  LootMgr: Stolen: false
[14:04]  LootMgr: ItemType: 53 - Essence Rune
[14:04]  LootMgr: Trait: 0 - None
[14:04]  LootMgr: Loot this: false
[14:04] 
[14:04]  LootMgr: REG >>> GetData() >>> INVENTORY_SINGLE_SLOT_UPDATE
[14:04]  LootMgr: Looted
[14:04]  LootMgr: CheckForEquip
[14:04]  LootMgr: REG >>> GetData() >>> INVENTORY_SINGLE_SLOT_UPDATE
[14:04]  LootMgr: UNREG <<< GetData() <<< INVENTORY_SINGLE_SLOT_UPDATE
[14:04]  LootMgr: Globals updated!
  Reply With Quote
08/08/19, 06:43 AM   #4
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,354
The loot event got no bagId or slotIndex afaik. It will be determined and shown in the small popup if you got autoloot all off. Else it will be looted.
And at the end the inventory will find the slot to update a given stack or to create a new slot and calls event_inventory_single_slot_update.

If you want to do checks as the event single slot update fires you could check the event_loot which provides an itemLink afaik. Store this itemLink in your addon's "toCheckInEventInvSIngleSlotUpdateTable[ItemlInk] = true. This might get you several items into the table which got looted before event_inv_single_slot_update gets raised.

Then in the events callback function check if the parameters like isNew ==true, inventory_update_reason is correct etc..
Create an itemLink from the bagId and slotIndex of the event. Check your table with the itemlinks if your created itemLink is in there and you got your needed bagid and slotIndex this way now.

Maybe there is an easier way as well if there is always a 1:1 connection between event_loot and event_single_slot_update. You could also simply use zo_callLater to wait for the inventoryData to be created properly (same as Votan said with RegisterForUpdate).
  Reply With Quote
08/08/19, 02:36 PM   #5
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
Thx a lot, guys. I got it running.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » When does the Game a frame forward?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off