Skip to content

TristonStuart/Yorg3ModWiki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 

Repository files navigation

YORG.io 3 Modding Wiki

Example Mods

Bigger Map Mod
No Fog Mod
Better Zombie Spawning
More Zoom Mod

These mods are all currently in use or are part of other mods, tobspr will not publish any of these to the mod gallery.

Getting Started

Getting started can be tricky!

The first thing you will need is the mod developer version of the game.
To get the mod dev version of the game use this link : https://beta.yorg3.io/?xdev_modDeveloper=1

This version is needed to install custom mods.
It will check for a mod file at http://localhost:8000/mod.js

You are probably wondering how to host your mod file at that address.
You can either make a file hosting server or use one of the ones that have already been made (Check below this).

File Hosting Servers

Node.js File Server : https://github.com/TristonStuart/Yorg3-Mod-Tools/tree/master/Mod.js%20File%20Server%20(nodejs)/ (Recomended)

Python File Server : https://github.com/tobspr/yorg.io-3-modding-docs/blob/master/sample_mod/mod_testing_server.py

ModBuild is a custom mod loader for mod developers.

It can :

  • Merge multiple mod files into one
  • Supports plugins
  • Supports AML api
  • Push mod projects to publishable mod

ModBuild is specifically designed for mod developers, to help make the creation of mods easier.

Code Snippets / Examples

Getting app

The app var is important for editing anything outside of the game variables.
Getting it is different across released and beta (as of 10/25/19), so 2 methods are shown.
The api variable must be accessible.

function getApp(api){return api.app;}
var app = api.app;
function getAppOld(api){return api.exportedVariables.Loader.app;}
var app = api.exportedVariables.Loader.app;

Getting API (Register Mod)

The api variable is needed as it is the mods connection point to the game, without it your mod can do nothing.
You will only need to register one mod function per mod.
The api variable is used for registering your mod implementation (check below) and also is your link to everything outside the game environment (aka main menu, settings, user details, and more).

function myMod(api){
  console.log('I got the api!');
  console.log(api);
}
window.registerMod(myMod);

Register Mod Implementation

Unlike when registering your mod to get the api (check above), your mod implementation will run everytime a game is started and will pass you the game variables through "root".
Any mod that wants to interact with the game will need to register a mod implementation.

function myMod(api){
  console.log('myMod is registered!');
  function modImplementation(root){
    console.log('Game has started! Got root!');
  }
  api.registerModImplementation(modImplementation);
}
window.registerMod(myMod);

Signals (Hook Functions To Game Events)

Signals are an important tool to hook certain functions to ingame events and processes.
Signals allow you to execute a function to draw something on screen (for example) everytime the game wants to draw a frame.

There are many signals : aboutToDestruct consumerPrioManuallyChanged damageDispatched dayNightChanged entityAdded entityDestroyed entityGotNewComponent entityQueuedForDestroy fullGameResync gameOver gameRejectedFromServer gameRestored gameSaved gameSyncedWithServer mapThemeLoaded modDrawScreenSpace modDrawWorldSpace modUpdateTick newlyUnlockedBuildingsChanged performAsync postLoadHook readyToRender requireRoutingUpdate resized skillsChanged streetDestroyed streetPlaced structureDestroyed structureEnhanced structurePlaced structureUpgraded

Example of how to add a hook to a signal :

root.signals.postLoadHook.add(function(){
  console.log('Game has fully loaded!');
});

About The Signals :

aboutToDestruct

Ran : Before Game Exits
Args : None

consumerPrioManuallyChanged

Ran : When building resource priority is changed
Args : [Building]

damageDispatched

Ran : When Zombie Attacks Something
Args : [DamageForm, Entity]

dayNightChanged

Ran : When day / night changes
Args : None

entityAdded

Ran : When an entity is created
Args : [Entity]

entityDestroyed

Ran : When an entity is destroyed
Args : [Entity]

entityGotNewComponent

Ran : When an entity gets a new component
Args : [Entity]

entityQueuedForDestroy

Ran : Before an entity is destroyed
Args : [Entity]

fullGameResync

Ran : In multiplayer when the server detected a simulation state mismatch, this resets the game to a previous point in time
Args : None

gameOver

Ran : When game ends
Args : None

gameRejectedFromServer

Ran : When the server does not accept the savegame (Invalid sync token / anticheat or mods)
Args : None

gameRestored

Ran : When game is restored (Called at the beginning when a savegame has been loaded)
Args : None

gameSaved

Ran : Unused
Args : None

gameSyncedWithServer

Ran : When game was successfully synced with server
Args : None

mapThemeLoaded

Ran : When map theme is fully loaded
Args : None

modDrawScreenSpace

Ran : Every frame
Args : [DrawParameters (contains e.g. the Canvas, Root and Zoom)]

modDrawWorldSpace

Ran : When rendering at world space
Args : [DrawParameters (contains e.g. the Canvas, Root and Zoom)]

modUpdateTick

Ran : Every tick
Args : None

newlyUnlockedBuildingsChanged

Ran : When new buildings are unlocked
Args : [Array<buildingId: string>]

performAsync

Ran : When the code needs to use async methods, those will be executed after the current logic step
Args : [callback: function() : void, name?: string]

postLoadHook

Ran : After game is loaded
Args : None

readyToRender

Ran : When game is ready to render
Args : None

requireRoutingUpdate

Ran : When game needs to make a routing update
Args : None

resized

Ran : When window is resized
Args : [width: number, height:number]

skillsChanged

Ran : When the skills are changed
Args : None

streetDestroyed

Ran : Unused
Args : [x, number, y:number]

streetPlaced

Ran : When a new street was placed
Args : [x: number, y:number]

structureDestroyed

Ran : When a structure is destroyed
Args : [Building]

structureEnhanced

Ran : When a structure is enhanced (not upgraded)
Args : [Entity]

structurePlaced

Ran : When a structure is placed
Args : [Entity]

structureUpgraded

Ran : When a structure is upgraded
Args : [Entity, Upgrade]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published