Skip to content

tobspr-games/Yorg3ModWiki

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 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 : [BuildingMeta]

damageDispatched

Ran : When Zombie Attacks Something
Args : [SpecificData (instaKill info), EntityMeta]

dayNightChanged

Ran : When day / night changes
Args : None

entityAdded

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

entityDestroyed

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

entityGotNewComponent

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

entityQueuedForDestroy

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

fullGameResync

Ran : (Not known - Might only be used in MP)
Args : Unknown

gameOver

Ran : When game ends
Args : None

gameRejectedFromServer

Ran : (Not known - Invalid sync token / anticheat or mods)
Args : Unknown

gameRestored

Ran : When game is restored from sync
Args : None

gameSaved

Ran : (Not known)
Args : Unknown

gameSyncedWithServer

Ran : When game is synced with server
Args : None

mapThemeLoaded

Ran : When map theme is fully loaded
Args : None

modDrawScreenSpace

Ran : Every frame
Args : [DrawParameters (Canvas - Mod Ui, Root, Zoom)]

modDrawWorldSpace

Ran : When rendering at world space
Args : [DrawParameters (Canvas, Root, Zoom)]

modUpdateTick

Ran : Every tick
Args : None

newlyUnlockedBuildingsChanged

Ran : When new building is unlocked
Args : [SpecificDataArray (Building Name)]

performAsync

Ran : When the code needs to use async
Args : [CallBackFunction?, Name]

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, Height]

skillsChanged

Ran : When the skills are changed
Args : None

streetDestroyed

Ran : Never (There is nothing using this signal and it is never called)
Args : Unknown

streetPlaced

Ran : (Not known)
Args : Unknown

structureDestroyed

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

structureEnhanced

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

structurePlaced

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

structureUpgraded

Ran : When a structure is upgraded
Args : [BuildingMeta, UpgradeMeta]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published