1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 18:21:51 +00:00
tobspr_shapez.io/mod_examples/class_extensions.js

33 lines
756 B
JavaScript
Raw Normal View History

2022-01-17 11:15:57 +00:00
// @ts-nocheck
2022-01-16 19:30:51 +00:00
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",
2022-01-22 08:03:42 +00:00
minimumGameVersion: "^1.5.0",
2022-01-16 19:30:51 +00:00
};
2022-01-17 18:11:04 +00:00
const BeltExtension = ({ $super, $old }) => ({
getShowWiresLayerPreview() {
// Access the old method
return !$old.getShowWiresLayerPreview();
},
getIsReplaceable() {
// Instead of super, use $super
return $super.getIsReplaceable.call(this);
},
2022-01-16 19:30:51 +00:00
2022-01-17 18:11:04 +00:00
getIsRemoveable() {
return false;
},
});
2022-01-16 19:30:51 +00:00
2022-01-17 18:11:04 +00:00
class Mod extends shapez.Mod {
init() {
this.modInterface.extendClass(shapez.MetaBeltBuilding, BeltExtension);
2022-01-16 19:30:51 +00:00
}
}