shapez/mod_examples
tobspr c41aaa1fc5
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft

* modloader features

* Refactor mods to use signals

* Add support for modifying and registering new transltions

* Minor adjustments

* Support for string building ids for mods

* Initial support for adding new buildings

* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading

* Lazy Load mods to make sure all dependencies are loaded

* Expose all exported members automatically to mods

* Fix duplicate exports

* Allow loading mods from standalone

* update changelog

* Fix mods folder incorrect path

* Fix modloading in standalone

* Fix sprites not getting replaced, update demo mod

* Load dev mod via raw loader

* Improve mod developing so mods are directly ready to be deployed, load mods from local file server

* Proper mods ui

* Allow mods to register game systems and draw stuff

* Change mods path

* Fix sprites not loading

* Minor adjustments, closes #1333

* Add support for loading atlases via mods

* Add support for loading mods from external sources in DEV

* Add confirmation when loading mods

* Fix circular dependency

* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods

* Add some mod signals

* refactor game loading states

* Make shapez exports global

* Start to make mods safer

* Refactor file system electron event handling

* Properly isolate electron renderer process

* Update to latest electron

* Show errors when loading mods

* Update confirm dialgo

* Minor restructure, start to add mod examples

* Allow adding custom themesw

* Add more examples and allow defining custom item processor operations

* Add interface to register new buildings

* Fixed typescript type errors (#1335)

* Refactor building registry, make it easier for mods to add new buildings

* Allow overriding existing methods

* Add more examples and more features

* More mod examples

* Make mod loading simpler

* Add example how to add custom drawings

* Remove unused code

* Minor modloader adjustments

* Support for rotation variants in mods (was broken previously)

* Allow mods to replace builtin sub shapes

* Add helper methods to extend classes

* Fix menu bar on mac os

* Remember window state

* Add support for paste signals

* Add example how to add custom components and systems

* Support for mod settings

* Add example for adding a new item type

* Update class extensions

* Minor adjustments

* Fix typo

* Add notification blocks mod example

* Add small tutorial

* Update readme

* Add better instructions

* Update JSDoc for Replacing Methods (#1336)

* upgraded types for overriding methods

* updated comments

Co-authored-by: Edward Badel <you@example.com>

* Direction lock now indicates when there is a building inbetween

* Fix mod examples

* Fix linter error

* Game state register (#1341)

* Added a gamestate register helper

Added a gamestate register helper

* Update mod_interface.js

* export build options

* Fix runBeforeMethod and runAfterMethod

* Minor game system code cleanup

* Belt path drawing optimization

* Fix belt path optimization

* Belt drawing improvements, again

* Do not render belts in statics disabled view

* Allow external URL to load more than one mod (#1337)

* Allow external URL to load more than one mod

Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.

* Update modloader.js

* Prettier fixes

* Added link to create-shapezio-mod npm page (#1339)

Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod

* allow command line switch to load more than one mod (#1342)

* Fixed class handle type (#1345)

* Fixed class handle type

* Fixed import game state

* Minor adjustments

* Refactor item acceptor to allow only single direction slots

* Allow specifying minimumGameVersion

* Add sandbox example

* Replaced concatenated strings with template literals (#1347)

* Mod improvements

* Make wired pins component optional on the storage

* Fix mod examples

* Bind `this` for method overriding JSDoc (#1352)

* fix entity debugger reaching HTML elements (#1353)

* Store mods in savegame and show warning when it differs

* Closes #1357

* Fix All Shapez Exports Being Const (#1358)

* Allowed setting of variables inside webpack modules

* remove console log

* Fix stringification of things inside of eval

Co-authored-by: Edward Badel <you@example.com>

* Fix building placer intersection warning

* Add example for storing data in the savegame

* Fix double painter bug (#1349)

* Add example on how to extend builtin buildings

* update readme

* Disable steam achievements when playing with mods

* Update translations

Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 16:35:49 +01:00
..
README.md Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
add_building_basic.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
add_building_flipper.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
base.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
buildings_have_cost.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
class_extensions.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
custom_css.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
custom_drawing.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
custom_keybinding.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
custom_sub_shapes.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
custom_theme.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
mirrored_cutter.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
mod_settings.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
modify_existing_building.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
modify_theme.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
modify_ui.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
new_item_type.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
notification_blocks.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
pasting.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
replace_builtin_sprites.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
sandbox.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
storing_data_in_savegame.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
translations.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00
usage_statistics.js Mod Support - 1.5.0 Update (#1361) 2022-02-01 16:35:49 +01:00

README.md

shapez.io Modding

General Instructions

Currently there are two options to develop mods for shapez.io:

  1. Writing single file mods, which doesn't require any additional tools and can be loaded directly in the game
  2. Using the create-shapezio-mod package. This package is still in development but allows you to pack multiple files and images into a single mod file, so you don't have to base64 encode your images etc.

Since the create-shapezio-mod package is still in development, the current recommended way is to write single file mods, which I'll explain now.

Mod Developer Discord

A great place to get help with mod development is the official shapez.io modloader discord.

Setting up your development environment

The simplest way of developing mods is by just creating a mymod.js file and putting it in the mods/ folder of the standalone (You can find the mods/ folder by clicking "Open Mods Folder" in the shapez.io Standalone, be sure to select the 1.5.0-modloader branch on Steam).

You can then add --dev to the launch options on Steam. This adds an application menu where you can click "Restart" to reload your mod, and will also show the developer console where you can see any potential errors.

Getting started

To get into shapez.io modding, I highly recommend checking out all of the examples in this folder. Here's a list of examples and what features of the modloader they show:

Example Description Demonstrates
base.js The most basic mod Base structure of a mod
class_extensions.js Shows how to extend multiple methods of one class at once, useful for overriding a lot of methods Overriding and extending builtin methods
custom_css.js Modifies the Main Menu State look Modifying the UI styles with CSS
replace_builtin_sprites.js Replaces all color sprites with icons Replacing builtin sprites
translations.js Shows how to replace and add new translations in multiple languages Adding and replacing translations
add_building_basic.js Shows how to add a new building Registering a new building
add_building_flipper.js Adds a "flipper" building which mirrors shapes from top to bottom Registering a new building, Adding a custom shape and item processing operation (flip)
custom_drawing.js Displays a a small indicator on every item processing building whether it is currently working Adding a new GameSystem and drawing overlays
custom_keybinding.js Adds a new customizable ingame keybinding (Shift+F) Adding a new keybinding
custom_sub_shapes.js Adds a new type of sub-shape (Line) Adding a new sub shape and drawing it, making it spawn on the map, modifying the builtin levels
modify_theme.js Modifies the default game themes Modifying the builtin themes
custom_theme.js Adds a new UI and map theme Adding a new game theme
mod_settings.js Shows a dialog counting how often the mod has been launched Reading and storing mod settings
storing_data_in_savegame.js Shows how to store custom (structured) data in the savegame Storing custom data in savegame
modify_existing_building.js Makes the rotator building always unlocked and adds a new statistic to the building panel Modifying a builtin building, replacing builtin methods
modify_ui.js Shows how to add custom IU elements to builtin game states (the Main Menu in this case) Extending builtin UI states, Adding CSS
pasting.js Shows a dialog when pasting text in the game Listening to paste events
sandbox.js Makes blueprints free and always unlocked Overriding builtin methods

Advanced Examples

Example Description Demonstrates
notification_blocks.js Adds a notification block building, which shows a user defined notification when receiving a truthy signal Adding a new Component, Adding a new GameSystem, Working with wire networks, Adding a new building, Adding a new HUD part, Using Input Dialogs, Adding Translations
usage_statistics.js Displays a percentage on every building showing its utilization Adding a new component, Adding a new GameSystem, Drawing within a GameSystem, Modifying builtin buildings, Adding custom game logic
new_item_type.js Adds a new type of items to the map (fluids) Adding a new item type, modifying map generation
buildings_have_cost.js Adds a new currency, and belts cost 1 of that currency Extending and replacing builtin methods, Adding CSS and custom sprites
mirrored_cutter.js Adds a mirorred variant of the cutter Adding a new variant to existing buildings

Creating new sprites

If you want to add new buildings and create sprites for them, you can download the original Photoshop PSD files here: https://static.shapez.io/building-psds.zip