From ea2f32b3ffe4f385a1c87196c10667e3157c50d5 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 15 Feb 2022 09:09:30 +0100 Subject: [PATCH] Fix examples --- mod_examples/new_item_type.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mod_examples/new_item_type.js b/mod_examples/new_item_type.js index 3f47d4d2..104ef0a0 100644 --- a/mod_examples/new_item_type.js +++ b/mod_examples/new_item_type.js @@ -87,7 +87,7 @@ class FluidItem extends shapez.BaseItem { * @param {number} diameter * @param {DrawParameters} parameters */ - drawItemCenteredClipped(x, y, parameters, diameter = globalConfig.defaultItemDiameter) { + drawItemCenteredClipped(x, y, parameters, diameter = shapez.globalConfig.defaultItemDiameter) { const realDiameter = diameter * 0.6; if (!this.cachedSprite) { this.cachedSprite = shapez.Loader.getSprite(`sprites/fluids/${this.fluidType}.png`); @@ -120,19 +120,19 @@ class Mod extends shapez.Mod { this.modInterface.registerSprite("sprites/fluids/water.png", RESOURCES["water.png"]); // Make the item spawn on the map - this.modInterface.runAfterMethod( - shapez.MapChunk, - "generatePatches", - function ({ rng, chunkCenter, distanceToOriginInChunks }) { - // Generate a simple patch - // ALWAYS use rng and NEVER use Math.random() otherwise the map will look different - // every time you resume the game - if (rng.next() > 0.8) { - const fluidType = rng.choice(Array.from(Object.keys(enumFluidType))); - this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]); - } + this.modInterface.runAfterMethod(shapez.MapChunk, "generatePatches", function ({ + rng, + chunkCenter, + distanceToOriginInChunks, + }) { + // Generate a simple patch + // ALWAYS use rng and NEVER use Math.random() otherwise the map will look different + // every time you resume the game + if (rng.next() > 0.8) { + const fluidType = rng.choice(Array.from(Object.keys(enumFluidType))); + this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]); } - ); + }); this.modInterface.registerItem(FluidItem, itemData => FLUID_ITEM_SINGLETONS[itemData]); }