diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 20:02:19 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:09:33 -0400 |
commit | da66780a569712c23ae4f2996cfb4608a9f9d69d (patch) | |
tree | 217556029a78bc23ad4564720afc86de97228a04 /digilines/digilines/util.lua | |
parent | 615b22df4d423aded3613db7716943a2f389b047 (diff) | |
download | dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2 dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip |
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'digilines/digilines/util.lua')
-rw-r--r-- | digilines/digilines/util.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/digilines/digilines/util.lua b/digilines/digilines/util.lua new file mode 100644 index 0000000..d138d63 --- /dev/null +++ b/digilines/digilines/util.lua @@ -0,0 +1,67 @@ +function digiline:addPosRule(p, r) + return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z} +end + +function digiline:cmpPos(p1, p2) + return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z) +end + +--Rules rotation Functions: +function digiline:rotate_rules_right(rules) + local nr={} + for i, rule in ipairs(rules) do + nr[i]={} + nr[i].z=rule.x + nr[i].x=-rule.z + nr[i].y=rule.y + end + return nr +end + +function digiline:rotate_rules_left(rules) + local nr={} + for i, rule in ipairs(rules) do + nr[i]={} + nr[i].z=-rules[i].x + nr[i].x=rules[i].z + nr[i].y=rules[i].y + end + return nr +end + +function digiline:rotate_rules_down(rules) + local nr={} + for i, rule in ipairs(rules) do + nr[i]={} + nr[i].y=rule.x + nr[i].x=-rule.y + nr[i].z=rule.z + end + return nr +end + +function digiline:rotate_rules_up(rules) + local nr={} + for i, rule in ipairs(rules) do + nr[i]={} + nr[i].y=-rule.x + nr[i].x=rule.y + nr[i].z=rule.z + end + return nr +end + +function digiline:tablecopy(table) -- deep table copy + if type(table) ~= "table" then return table end -- no need to copy + local newtable = {} + + for idx, item in pairs(table) do + if type(item) == "table" then + newtable[idx] = digiline:tablecopy(item) + else + newtable[idx] = item + end + end + + return newtable +end |