A metatable can be defined like
local t = setmetatable({}, {
__tostring = function() return 'custom tostring behavior!' end
})
Here are the metamethods that you can define, and their behavior
---@meta | |
xdrv = {} | |
-- how to get these | |
-- grab the list of mods from https://github.com/EX-XDRiVER/Chart-Documentation/blob/main/mods.md, then do the following: | |
-- | |
-- 1: replace: -- "(\w+)"( \("(\w+)"\))?\s*\n-- - .+\n(--\s*\n)? | |
-- with : '$1' | '$3' | | |
-- 2: replace: \| '' \| |
local sm = {} | |
local function filterComments(text) | |
local lines = {} | |
for line in string.gmatch(text, '([^\n\r]*)[\n\r]?') do | |
if not string.match(line, '^%s*//.+') and string.len(line) > 0 then | |
table.insert(lines, line) | |
end | |
end | |
return table.concat(lines, '\n') |
Well I'm glad you asked, because this simple question has many anwsers depending on how much effort you want to put in!
There are 3 types of random you can use in Isaac, going from the one that requires the least amount of effort to the one that requires the most amount of effort. There is no "objectively best" method, as it depends on your usecase, the size of your mod, and how much you truly care.
For this guide, let's assume your usecase is for adding a random vector to an entity's velocity:
-- smelte 1.0 | |
-- a very, very dumb proof-of-concept Lua DSL HTML framework | |
-- | |
-- smelte.declare 'name' (function() return span 'custom element' end) | |
-- -> void | |
-- declares a custom element | |
-- | |
-- smelte.compile (function() return | |
-- { | |
-- head = { |
local uwuify = require 'uwu' | |
assert(uwuify('really') == 'weawwy') |
-- constants | |
SCREEN_WIDTH = 24 | |
SCREEN_HEIGHT = 24 | |
sw, sh = SCREEN_WIDTH, SCREEN_HEIGHT | |
-- timer | |
local ticks = 0 | |
local time = 0 |
// skills | |
function calculateSkill(exp, mult = 1) { | |
return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1); | |
} | |
function calculateExp(skill, mult = 1) { | |
return Math.exp((skill / mult + 200) / 32) - 534.6; | |
} |
-- isaac-related luacheck config | |
-- please use luacheck while possible!! | |
-- if you disagree with any of the policies given here | |
-- id suggest you discuss it with the team before you change it | |
-- (unless its a global mistake or similar) | |
return { | |
-- isaac has lots of globals and doesnt just drop them into one Isaac | |
-- namespace like the name would imply. fun! |
// rhythmbox database collage tool | |
// | |
// dependencies: jimp, xml-js | |
// | |
// this code is licensed under a [copyleft](https://en.wikipedia.org/wiki/Copyleft) license: this code is completely okay to modify, copy, redistribute and improve upon, as long as you keep this license notice | |
// ↄ Jill "oatmealine" Monoids 2021 | |
const Jimp = require('jimp'); | |
const fs = require('fs'); | |
const { xml2js } = require('xml-js'); |