olegbl / d2rmm

Mod Manager for Diablo II: Resurrected
https://www.nexusmods.com/diablo2resurrected/mods/169
MIT License
54 stars 9 forks source link

Object.keys() doesn't work? #5

Closed andrecastelo closed 1 year ago

andrecastelo commented 1 year ago

Hey man, love the work with D2RMM. I'm playing around with a mod, trying to refactor some code, and while trying to use Object.keys(...) I get this:

image

Is this a limitation on electron or on the way that the mod code is executed?

olegbl commented 1 year ago

See "Mod API" section in https://www.nexusmods.com/diablo2resurrected/mods/169

Note: The JavaScript inside this file is run without access to the global scope. (e.g. You’ll need to use for/in instead of Object.keys since Object is not available). The Math API is exposed for you, however.

Basically, this is one of the limitations originally imposed to try to sandbox the mods and prevent them from doing something harmful.

andrecastelo commented 1 year ago

Thanks for the clarification!