Pet Weight & Income Sample Module

A transparent Luau helper that compares two same-species weight and income observations without assuming weight has one universal multiplier.

Roblox Studio ModuleScript

What this script does

Measure relative differences between project-owned samples and keep species boundaries explicit before drawing a conclusion.

Best for
Controlled balancing tests where two instances of the same pet or producer have different observed values.
Language
Luau
Version
1.0.0
Validation
Luau runtime tested
Luau runtime tested

Official Luau 0.735 parsing and strict analysis pass, and the module is covered by the pure-module runtime behavior harness.

Included behavior

  • Same-species validation
  • Relative weight and income changes
  • Best observed sample helper

Install in the stated runtime

  1. 1
    Create a ModuleScript named PetSamples.
  2. 2
    Paste the complete source and require it from a server or test Script in your own experience.
  3. 3
    Pass samples from a controlled project test and keep mutation, level, and other modifiers constant where possible.

Minimal usage example

local PetSamples = require(script.Parent.PetSamples)
local comparison = PetSamples.compare(
	{ species = "Fox", weight = 10, incomePerSecond = 100 },
	{ species = "Fox", weight = 12, incomePerSecond = 130 }
)
print(comparison.weightChange, comparison.incomeChange)

Example inputs and result

Supply
Two same-species observations with weight and income per second.
Expect
compare returns the observed weight and income changes, not a species formula.

These notes explain the example above. Read the complete source for every exported function and edge case before integrating it.

Complete source

No hidden import, minified block, or shortened loader.

--!strict
-- MIT License. Compares observed same-species samples without inventing a universal weight multiplier.

export type PetSample = { species: string, weight: number, incomePerSecond: number }

local PetSamples = {}

local function validate(sample: PetSample)
	assert(sample.species ~= "", "Species cannot be empty")
	assert(sample.weight > 0, "Weight must be positive")
	assert(sample.incomePerSecond >= 0, "Income must be non-negative")
end

function PetSamples.compare(first: PetSample, second: PetSample)
	validate(first)
	validate(second)
	assert(first.species == second.species, "Only compare samples of the same species")
	return {
		species = first.species,
		weightDifference = second.weight - first.weight,
		weightChange = (second.weight - first.weight) / first.weight,
		incomeDifference = second.incomePerSecond - first.incomePerSecond,
		incomeChange = if first.incomePerSecond == 0 then nil else (second.incomePerSecond - first.incomePerSecond) / first.incomePerSecond,
		firstIncomePerWeight = first.incomePerSecond / first.weight,
		secondIncomePerWeight = second.incomePerSecond / second.weight,
	}
end

function PetSamples.bestObserved(samples: { PetSample }): PetSample?
	local best: PetSample? = nil
	for _, sample in samples do
		validate(sample)
		if best == nil or sample.incomePerSecond > best.incomePerSecond then best = table.clone(sample) end
	end
	return best
end

return table.freeze(PetSamples)
SHA-256e7148f57ecbab393f3d6ddffb5f3f481bb617274e9205d976caeb5493bd76414

Outside this script’s scope

  • Infer a hidden Steal An Egg formula
  • Compare different species as if weight were the only variable

Found a problem or a better approach?

Tell us what failed, what you expected, and whether the issue happened in the Luau CLI or Roblox Studio. Suggestions for clearer types, safer server checks, or a more useful API are welcome.

Do not submit credentials, private project files, or account data.