Skip to content

Instantly share code, notes, and snippets.

@tonetheman
Created August 29, 2022 22:54
Show Gist options
  • Save tonetheman/98685968d020c673b6e8c58f6cc99bee to your computer and use it in GitHub Desktop.
Save tonetheman/98685968d020c673b6e8c58f6cc99bee to your computer and use it in GitHub Desktop.
lua code for a mod that works for 1 based numbers
--[[
saw this buried in this code
https://www.lexaloffle.com/bbs/?tid=49068
]]--
function mod(val,modulo)
--Mod for 1 based numbers.
--3%3=3. 4%3=1, 1%3=1
return (val-1)%modulo+1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment