Kube JS Event Firing Integration
gr8pefish opened this issue ยท 4 comments
Looking for events I can view via KubeJS for Modonomicon, so I can ideally do something like the following pseudocode:
onEvent('modonomicon.conditions.entry_read.1208433', event => {
print("Finished reading custom entry with id: " + 1208433)
event.player.stage = 'Stage2'
print("Setting player to stage 2")
})
Implementation Specifics
Ideal events:
- Everything under the Unlock Conditions, most notably
entry_read
andadvancement
Additional context
- See here for an implementation example in FTB Quests (and here for the end user result of that)
- My use case is Forge 1.18, so that's the ideal target version
Cheers!
@gr8pefish theoretically the plugin is done, but somehow KubeJS is not calling it (it finds the plugin, but doesn't use it, and doesn't throw an error .. yay). I opened a support thread in the KubeJS Discord and once a solution is available I will release it
Edit: turns out it was a silly mistake in the plugin loader config that apparently KubeJS is not logging. Works now on 1.19.2.
Will have to see about 1.18 because apparently kubejs works very different for that version
ModonomiconEvents.updateUnlockedContent(event => {
console.info(event.getUnlockedContent().length);
})
ModonomiconEvents.categoryUnlocked(event => {
console.info(event.getCategory().getId());
})
ModonomiconEvents.entryUnlocked(event => {
console.info(event.getEntry().getId());
})
ModonomiconEvents.entryRead(event => {
console.info(event.getEntry().getId());
})
There's now 4 events. updateUnlockedContent contains a list of all unlocked contents (categories + entries) that happen in one update cycle (e.g. if someone clicked the "read all" button). Additionally for each unlocked content one of the two specific events fire.
Finally entryRead fires whenever an entry is read for the first time - it will then fire the unlockedEvents if any content was unlocked by this read action.
For 1.18.2 that would read:
onEvent('modonomicon.update_unlocked_content', event => {
console.info(event.getUnlockedContent().length);
})
onEvent('modonomicon.category_unlocked', event => {
console.info(event.getCategory().getId());
})
onEvent('modonomicon.entry_unlocked', event => {
console.info(event.getEntry().getId());
})
onEvent('modonomicon.entry_read', event => {
console.info(event.getEntry().getId());
})