You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tobspr_shapez.io/mod_examples/class_extensions.js

33 lines
807 B

// @ts-nocheck
const METADATA = {
website: "https://tobspr.io",
author: "tobspr",
name: "Mod Example: Class Extensions",
version: "1",
id: "class-extensions",
description: "Shows how to extend builtin classes",
minimumGameVersion: ">=1.5.0",
};
const BeltExtension = ({ $super, $old }) => ({
getShowWiresLayerPreview() {
// Access the old method
return !$old.getShowWiresLayerPreview();
},
getIsReplaceable(variant, rotationVariant) {
// Instead of super, use $super
return $super.getIsReplaceable.call(this, variant, rotationVariant);
},
getIsRemoveable() {
return false;
},
});
class Mod extends shapez.Mod {
init() {
this.modInterface.extendClass(shapez.MetaBeltBuilding, BeltExtension);
}
}