Project Zomboid

Project Zomboid

Eggon's Modding Utils
 Denne tråd er blevet fastgjort, så den er sikkert vigtig
Eggon  [udvikler] 3. okt. 2021 kl. 2:40
Guide: Events
Introduction
The mod is work in progress and I will try to improve the contents (in particular the events) overtime.

All events offered by this mod work on a similar principle: a relevant PZ's core function is stored in a new variable and the original reference (name) is overwritten by this mod's function that triggers the event, in some cases performs some minimal follow-up logic and re-calls the original PZ function.

This means that if IndieStone significantly change the core function, it will break the game and you need to be aware of it when using this mod. However, I think the probability of them doing this in such a destructive way is relatively low.

Nonetheless, in order to minimize the risk (and to improve performance) each of the events needs to be enabled before you use them. Enable just the events that you will be using.
Sidst redigeret af Eggon; 29. okt. 2021 kl. 3:30
< >
Viser 1-9 af 9 kommentarer
Eggon  [udvikler] 3. okt. 2021 kl. 2:46 
Enabling events

In order to enable a particular event place the following code into a file in lua/client directory:

if EggonsMU then EggonsMU.config.enableEvent("OnHotbarItemAttach") end

The example uses OnHotbarItemAttach. Use the name of relevant event.
Sidst redigeret af Eggon; 10. nov. 2021 kl. 8:03
Eggon  [udvikler] 3. okt. 2021 kl. 3:07 
OnHotbarItemAttach event

Event triggers when item is attached to a hotbar, but also during hotbar refreshes, so it will be triggered before game starts, but also in some other cases, like when a backpack is equipped. A series of unattach/attach events might be triggered, but the an 'attach' will be triggered as last. It is definitely not optimal, but at this moment I don't know how to circumvent it. The event is triggered rarely enough to not have impact on performance even if slightly unoptimal.

The handler fnction receives the following parameters:
1) item - item being attached
2) slot - hotbar slot it is being attached to
3) slotIndex - index of the hotbar slot
4) slotDef
5) doAnim - will animation be performed. Generally the technical, 'refresh', triggers will have this value as false.

Enabling function: EggonsMU.config.enableEvent("OnHotbarItemAttach")
Sidst redigeret af Eggon; 14. okt. 2021 kl. 4:48
Eggon  [udvikler] 3. okt. 2021 kl. 3:11 
OnHotbarItemUnattach event

Event triggers when item is unattached from the hotbar, but also during hotbar refreshes, so it will be triggered before game starts, but also in some other cases, like when a backpack is equipped. A series of unattach/attach events might be triggered, but in case of the refresh actions an 'attach' will be triggered as last. If an item is really removed from the hotbar, the 'unattach' event will trigger as last, but it might trigger more than once. It is definitely not optimal, but at this moment I don't know how to circumvent it. The event is triggered rarely enough to not have impact on performance even if slightly unoptimal.

The handler fnction receives the following parameters:
1) item - item being unattached

Enabling function: EggonsMU.config.enableEvent("OnHotbarItemUnattach")
Sidst redigeret af Eggon; 14. okt. 2021 kl. 4:48
Eggon  [udvikler] 8. okt. 2021 kl. 9:50 
OnBeforeItemTransfer event

The handler function receives a single argument consisting of the following properties:

1) eventData = {
    character,
    item, -- item being transferred
    srcContainer, -- source container
    destContainer, -- destination container, can be replaced by a different one
    cancel, -- set true to cancel action
}

Example of use:
function OnBeforeItemTransferHandler (eventData) eventData.cancel = true -- will cancel the event eventData.destContainer = yourContainer -- will replace destination container with a different one end Events.OnBeforeItemTransfer.Add(OnBeforeItemTransferHandler)

Enabling function: EggonsMU.config.enableEvent("OnBeforeItemTransfer")
Sidst redigeret af Eggon; 10. nov. 2021 kl. 8:04
Eggon  [udvikler] 8. okt. 2021 kl. 9:59 
OnAfterItemTransfer event

The handler function receives the following arguments:
    1 .character,
    2. item, -- item being transferred
    3. srcContainer, -- source container
    4. destContainer, -- destination container

Enabling function: EggonsMU.config.enableEvent("OnAfterItemTransfer")
Sidst redigeret af Eggon; 14. okt. 2021 kl. 4:49
Eggon  [udvikler] 14. okt. 2021 kl. 4:56 
OnBeforeFirstInventoryTooltipDisplay event

This event triggers once only when inventory tooltip is displayed for the first time for a particular item (A). If mouse is moved over another item (B) it will trigger again for that new item (B) and if mouse is moved over item A again - it will trigger for item A. However, if tooltip for item (A) is displayed and mouse is moved outside of inventory (tooltip disappears) and then moved again onto the same item (A), the event will not trigger again despite the tooltip being displayed.

The handler function receives the following arguments:
    1. item, -- item being hovered over
    2. ISToolTipInv_instance, -- instance of ISToolTipInv

Enabling function: EggonsMU.config.enableEvent("OnBeforeFirstInventoryTooltipDisplay")
Sidst redigeret af Eggon; 10. nov. 2021 kl. 8:08
Eggon  [udvikler] 15. nov. 2021 kl. 7:02 
OnDisplayContainerContents event
OnDisplayInventoryContainerContents event
OnDisplayLootContainerContents event

These events trigger when new container gets activated in the inventory panes. It does not work with 'floor'.
OnDisplayContainerContents - triggers when either inventory or loot container gets activated
OnDisplayInventoryContainerContents - triggers for inventory containers only
OnDisplayLootContainerContents - triggers for loot containers only

The handler function receives the following arguments:
    1. ItemsContainer, -- container being activated
Enabling functions:
EggonsMU.enableEvent.OnDisplayContainerContents()
EggonsMU.enableEvent.OnDisplayLootContainerContents()
EggonsMU.enableEvent.OnDisplayInventoryContainerContents()
Sidst redigeret af Eggon; 15. nov. 2021 kl. 7:03
Eggon  [udvikler] 15. nov. 2021 kl. 7:05 
U+274B
[U+274B]
:U+274B:
🗜
Sidst redigeret af Eggon; 15. nov. 2021 kl. 7:06
HapiHapiHapi 30. juli 2023 kl. 0:45 
Where can I find the Lua/client directory?
< >
Viser 1-9 af 9 kommentarer
Per side: 1530 50