#How do you listen to events from other mods?

26 messages · Page 1 of 1 (latest)

wide bay
#

Ngl in actuality I'm not even trying to use KubeJS. I'm a mod dev and my mod has custom events and I want to know what to put in the documentation for it lmao

sacred lintelBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

wide bay
wide bay
#

i figured... parts of it out

#

its kind of awful and i hate it

#

apparently this might be because it's interpreting the map as a json, which means it can only have string keys

#

which

#

is sucks

zenith swallow
#

JavaScript object access can only use string or symbol keys

#

I really have no idea why KJS devs let one access a Java map like a JS object

#

You can try using a ⁨put⁩ method on the map, which should allow you to insert anything as a key

#

As the Map should do

#

So, instead of:
⁨```js
event.geneWeights[cringeGene] = 1.0;

do
⁨```js
event.geneWeights.put(toGeneRk("geneticsresequenced:cringe"), 1)
```⁩
#

(⁨.0⁩) at the end of a number does not matter, all numbers in JS are like Java ⁨double⁩ anyway

zenith swallow
wide bay
#

It said object doesn't have put method

zenith swallow
#

Yay, KubeJS wrecks basic map access

#

The only thing I could suggest is to make some sort of a proxy that is exposed to scripts that will expose the necessary methods of a map

#

While still being able to set anything as key

wide bay
#

I could theoretically add a new method to the event