Project Zomboid

Project Zomboid

Events Plus API
 此主题已被置顶,因此可能具有重要性
Dismellion  [开发者] 2024 年 6 月 21 日 上午 11:17
Bugs & Troubleshooting
Post anything related to the mod issues.
< >
正在显示第 1 - 7 条,共 7 条留言
Dismellion  [开发者] 2024 年 6 月 21 日 上午 11:17 
reserved
MaeTheHyena 2024 年 7 月 31 日 上午 7:30 
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  [开发者] 2024 年 8 月 3 日 下午 4:01 
引用自 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 2024 年 8 月 14 日 上午 6:49 
引用自 Dismellion
引用自 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.
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  [开发者] 5 月 1 日 上午 3:44 
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.
< >
正在显示第 1 - 7 条,共 7 条留言
每页显示数: 1530 50