Go to file
2025-04-16 09:37:05 +02:00
dev Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
.luacheckrc Adds luacheck 2025-04-16 05:44:59 +02:00
api.lua Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00
config.lua Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00
information.lua Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
init.lua Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
initialize.lua Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
internal.lua Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00
LICENSE-CC0 Initial commit 2025-04-03 06:49:33 +02:00
LICENSE-MIT Initial commit 2025-04-03 06:49:33 +02:00
LICENSE.md Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
mod.conf Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00
README.md Changes template to ruleset namespace, adds readme, adds examples 2025-04-16 05:44:29 +02:00
screenshot.png Initial commit 2025-04-03 06:49:33 +02:00
settingtypes.txt Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00
texts.lua Implements registrations and removes unnecessary files 2025-04-16 09:37:05 +02:00

yl_rulesets

Purpose

This mod is a library to create, apply and reset rulesets. Rulesets in the sense of this mod are a group of mechanics, settings or other ways to alter what the server does. One example of a ruleset may be "All mobs drop double the amount of items and award three times the xp, but are four times as dangerous as usual" or "All mobs drop half the amount of items and award half the xp, but are also only half as dangerous as usual"

Terms and definitions

In the context of this mod a rule is a single alteration to the server. For example "mobs drops are halved" or "mobs drops are twice as common". To apply a number of rules at the same time, they are aggregated in a ruleset. Individual rules cannot be enabled or disabled on their own. They must be part of a ruleset, which is applied as a whole. The mod makes sure that within a ruleset_group only one ruleset is active at the same time.

Download

Get it from https://gitea.your-land.de/your-land/yl_rulesets

Dependencies

See mod.conf

Installation

  1. Copy the "yl_rulesets" folder to your mod directory.
  2. Make sure the dependencies are satisfied, if any.
  3. Enable the mod in your world.mt file.

Configuration

yl_rulesets.debug = false

Set to true to enable debug mode

Usage

This mod targets servers, but should work in singleplayer, too. It comes with no direct content but exposes functions you can use in your mod.

Define one or more ruleset_group per mod. Create rulesets between which you will switch and assign rules you create to those rulesets. Each rule needs a function that is executed when the rule is activated and another function that rolls back the rules once you switch to another ruleset. Then, during operation, switch between rulesets as you need. Make sure to cleanly separate rules from each other and rulesets, so that you don't overwrite one rule with a another rule from a different set. It makes sense to group the rules thematically.

Chatcommands

None so far

Modmakers

Use the following public functions to create rules, rulesets and ruleset_groups and switch between them:

yl_rulesets.register_ruleset_group("ruleset_group_name")

Creates a ruleset_group of the name "ruleset_group_name". Returns true, "" if the ruleset group was successfully created. Returns false, "errormessage" if the ruleset group cannot be created.

yl_rulesets.register_ruleset("ruleset_name", "ruleset_group_name")

Creates a ruleset of the name "ruleset_name" as member of the "ruleset_group_name" ruleset group. Returns true, "" if the ruleset was successfully created. Returns false, "errormessage" if the ruleset cannot be created.

yl_rulesets.register_rule("rulename", "ruleset_name", "ruleset_group_name", function_activate, function_deactivate, {options})

Creates a rule of the name "rule_name" and adds it to the ruleset "ruleset_name" of group "ruleset_group_name". function_activate is the function that gets executed when this rule comes into effect. function_deactivate is the rule that rolls back what the activation changed. options is a table of options, see below. Returns true, "" if the rule was successfully created. Returns false, "errormessage" if the rule cannot be created.

yl_rulesets.enable("ruleset_group", "ruleset")

Enables a ruleset of a given ruleset_group. All deactivate-functions of the previous ruleset are executed and all activate functions of the given ruleset are executed. Returns true, number_of_rules if the ruleset was successfully activated. Returns false, "errormessage" if the ruleset was not successfully activated.

function_activate()
function_deactivate()

These are the functions that are executed, when a rule is activated or deactivated. Must return true on success and must return false on failure.

Limitations

  • This mod does not police what is in rules.
  • It cannot make sure rulesets don't overwrite each other's or other ruleset_groups' rules

Alternatives

  • Apply and roll back the rules manually

Supported versions

If you use yl_rulesets, but something is wrong, please file a bug. PRs also welcome.

There is no reason to believe it doesn't work anywhere, but you never know.

Allied projects

If you know a project that uses this mod tell us and we will add it to the list.

Uninstall

Remove it from your mod folder or deactivate it in your world.mt

Mods that depend on it will cease to work, if the mod is removed without proper replacement.

License

See LICENSE.md

  • Code MIT AliasAlreadyTaken
  • Screenshot CC0 Styxcolor

Thank you