hm
This commit is contained in:
4
mods/i3/tests/test_compression.lua
Normal file
4
mods/i3/tests/test_compression.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
i3.compress("default:diamondblock", {
|
||||
replace = "diamond",
|
||||
by = {"bronze", "copper", "gold", "steel", "tin"}
|
||||
})
|
||||
338
mods/i3/tests/test_custom_recipes.lua
Normal file
338
mods/i3/tests/test_custom_recipes.lua
Normal file
@@ -0,0 +1,338 @@
|
||||
local mt = ItemStack("default:wood")
|
||||
mt:get_meta():set_string("description", "test wood")
|
||||
mt:get_meta():set_string("color", "green")
|
||||
|
||||
local mt2 = ItemStack("dye:red")
|
||||
mt2:get_meta():set_string("description", "test red")
|
||||
mt2:get_meta():set_string("color", "#ff0")
|
||||
|
||||
local mt3 = ItemStack("default:pick_diamond")
|
||||
mt3:get_meta():set_string("description", "Worn Pick")
|
||||
mt3:get_meta():set_string("color", "yellow")
|
||||
mt3:set_wear(10000)
|
||||
|
||||
minetest.register_craft {
|
||||
output = mt:to_string(),
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"default:wood",
|
||||
mt2:to_string(),
|
||||
},
|
||||
}
|
||||
|
||||
minetest.register_craft {
|
||||
output = mt3:to_string(),
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"default:pick_mese",
|
||||
"default:diamond",
|
||||
},
|
||||
}
|
||||
|
||||
minetest.clear_craft {
|
||||
recipe = {
|
||||
{"default:sand", "default:sand"},
|
||||
{"default:sand", "default:sand"},
|
||||
},
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
result = "default:ladder_wood 2",
|
||||
items = {"default:copper_ingot 7, default:tin_ingot, default:steel_ingot 2"},
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
result = "default:tree",
|
||||
items = {
|
||||
"default:wood",
|
||||
"",
|
||||
"default:wood"
|
||||
},
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
result = "default:cobble 16",
|
||||
items = {
|
||||
"default:stone, default:stone",
|
||||
"default:stone, , default:stone",
|
||||
", default:stone, default:stone",
|
||||
}
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X",
|
||||
"#",
|
||||
"X",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X",
|
||||
"#X",
|
||||
"X",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X#",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X#XX",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X#XX",
|
||||
"X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X#XX",
|
||||
"X#X",
|
||||
"#",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X##XX",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X##X#X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X##X#X",
|
||||
"",
|
||||
"X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"X X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass 2",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#X",
|
||||
"X X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##",
|
||||
" ## ",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##X",
|
||||
" ## ",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##X#",
|
||||
" ## ",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##X#X",
|
||||
" ## ",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
|
||||
i3.register_craft {
|
||||
grid = {
|
||||
"X #",
|
||||
" ## ",
|
||||
"X#X#",
|
||||
"#X#X#",
|
||||
"X X##X#X",
|
||||
" ## ",
|
||||
"#X#X#",
|
||||
"#X#X#",
|
||||
},
|
||||
key = {
|
||||
['#'] = "default:wood",
|
||||
['X'] = "default:glass",
|
||||
},
|
||||
result = "default:mese 3",
|
||||
}
|
||||
8
mods/i3/tests/test_online_recipe.json
Normal file
8
mods/i3/tests/test_online_recipe.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"items": [
|
||||
"default:stone, default:stone, default:stone",
|
||||
"default:stone, , default:stone",
|
||||
"default:stone, default:stone, default:stone"
|
||||
],
|
||||
"result": "default:cobble 16"
|
||||
}
|
||||
26
mods/i3/tests/test_operators.lua
Normal file
26
mods/i3/tests/test_operators.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local a, b, c = 0, 0, 0
|
||||
b+=1
|
||||
c++; local foo = "bar";
|
||||
local t = {
|
||||
a = a++,
|
||||
b = 2,
|
||||
c = c+=2,
|
||||
d = a&3,
|
||||
e = 1,
|
||||
}
|
||||
t["b"] <<= 4
|
||||
t.b >>= 2
|
||||
assert(t.b == 8)
|
||||
--print(dump(t))
|
||||
--c += 1
|
||||
c*=2
|
||||
local i = 16
|
||||
i += i<<4
|
||||
assert(i == 272)
|
||||
assert((a+=2) == 2)
|
||||
assert(c++ == 3)
|
||||
assert((a-=1) == -1)
|
||||
assert((c^=4) == 16)
|
||||
assert((a&b) == 0)
|
||||
assert((c|=a) == 2)
|
||||
assert((1<<8) == 256)
|
||||
34
mods/i3/tests/test_tabs.lua
Normal file
34
mods/i3/tests/test_tabs.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
i3.new_tab("test1", {
|
||||
description = "Test 1 Test 1",
|
||||
image = "i3_heart.png",
|
||||
|
||||
formspec = function(player, data, fs)
|
||||
fs("label", 3, 1, "Just a test")
|
||||
fs"label[3,2;Lorem Ipsum]"
|
||||
end,
|
||||
})
|
||||
|
||||
i3.new_tab("test2", {
|
||||
description = "Test 2",
|
||||
image = "i3_mesepick.png",
|
||||
|
||||
formspec = function(player, data, fs)
|
||||
fs("label[3,1;Test 2]")
|
||||
end,
|
||||
})
|
||||
|
||||
i3.new_tab("test_creative", {
|
||||
description = "Test creative",
|
||||
|
||||
access = function(player, data)
|
||||
local name = player:get_player_name()
|
||||
return core.is_creative_enabled(name)
|
||||
end,
|
||||
|
||||
formspec = function(player, data, fs)
|
||||
fs("label[3,1;Creative enabled]")
|
||||
end,
|
||||
|
||||
fields = i3.set_fs,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user