Project Zomboid

Project Zomboid

Events Plus API
 This topic has been pinned, so it's probably important
Dismellion  [developer] 21 Jun, 2024 @ 11:17am
Bugs & Troubleshooting
Post anything related to the mod issues.
< >
Showing 1-7 of 7 comments
Dismellion  [developer] 21 Jun, 2024 @ 11:17am 
reserved
MaeTheHyena 31 Jul, 2024 @ 7:30am 
Pretty new to modding, can't get the event trigger to work. Have asked around and searched the web, without success. I think I don't understand the documentation well. How would a simple trigger like this look when correctly made?

require("TimedActions/ISDrinkFromBottle.lua") require("EventsPlusMain.lua") local function testingFunction() print("Player drank an item!") end EventsPlus:Add("OnDrink", testingFunction, "Drink Event Handler")

I've tried a lot of variations on this, so the specifics might be further from working than when I started.
Dismellion  [developer] 3 Aug, 2024 @ 4:01pm 
Originally posted by MaeTheHyena:
Pretty new to modding, can't get the event trigger to work. Have asked around and searched the web, without success. I think I don't understand the documentation well. How would a simple trigger like this look when correctly made?

require("TimedActions/ISDrinkFromBottle.lua") require("EventsPlusMain.lua") local function testingFunction() print("Player drank an item!") end EventsPlus:Add("OnDrink", testingFunction, "Drink Event Handler")

I've tried a lot of variations on this, so the specifics might be further from working than when I started.

I think it doesn't trigger for auto-drinking if that's the case you are testing, only manual usage from inventory. I will run your code tomorrow to see.
MaeTheHyena 14 Aug, 2024 @ 6:49am 
Originally posted by Dismellion:
Originally posted by MaeTheHyena:
Pretty new to modding, can't get the event trigger to work. Have asked around and searched the web, without success. I think I don't understand the documentation well. How would a simple trigger like this look when correctly made?

require("TimedActions/ISDrinkFromBottle.lua") require("EventsPlusMain.lua") local function testingFunction() print("Player drank an item!") end EventsPlus:Add("OnDrink", testingFunction, "Drink Event Handler")

I've tried a lot of variations on this, so the specifics might be further from working than when I started.

I think it doesn't trigger for auto-drinking if that's the case you are testing, only manual usage from inventory. I will run your code tomorrow to see.

I was testing it with drinking pop and orange soda, couldn't get it to trigger. Did it work on your end?
Heyya, when I call the event OnEat it calls roughly 4 times. I'll post my code real quick.

EventsPlus:Add("OnEat", function(character, item, percentage)
carbs = item:getCarbohydrates()
character:Say(carbs)
end, "My callback context")

This for some reason makes the character say the variable carbs 4 times back to back.
Originally posted by throwing (chat muted):
Heyya, when I call the event OnEat it calls roughly 4 times. I'll post my code real quick.

EventsPlus:Add("OnEat", function(character, item, percentage)
carbs = item:getCarbohydrates()
character:Say(carbs)
end, "My callback context")

This for some reason makes the character say the variable carbs 4 times back to back.


So I actually fixed this, and it must have something to do with the ctor because I added "False" for the bool at the end and it works fine now.
Dismellion  [developer] 1 May @ 3:44am 
Originally posted by throwing (chat muted):
Originally posted by throwing (chat muted):
Heyya, when I call the event OnEat it calls roughly 4 times. I'll post my code real quick.

EventsPlus:Add("OnEat", function(character, item, percentage)
carbs = item:getCarbohydrates()
character:Say(carbs)
end, "My callback context")

This for some reason makes the character say the variable carbs 4 times back to back.


So I actually fixed this, and it must have something to do with the ctor because I added "False" for the bool at the end and it works fine now.

Note that Events have stack, meaning it will fire the event as much times as much you have added them. There are documentation on how to remove particular events or whole stack in the mod description.
< >
Showing 1-7 of 7 comments
Per page: 1530 50