From e93a42e5b4663430da7814a9235a65be37d33255 Mon Sep 17 00:00:00 2001 From: cale Date: Fri, 5 Feb 2016 12:48:46 +0100 Subject: [PATCH] added juice and potions code cleanup --- mods/juice/LICENSE.txt | 16 +++ mods/juice/depends.txt | 2 + mods/juice/depends.txt~ | 2 + mods/juice/init.lua | 77 ++++++++++++ mods/juice/init.lua~ | 77 ++++++++++++ mods/juice/textures/juice_apple.png | Bin 0 -> 291 bytes mods/juice/textures/juice_cactus.png | Bin 0 -> 291 bytes mods/juice/textures/juice_glass.png | Bin 0 -> 250 bytes mods/juice/textures/juice_strawberry.png | Bin 0 -> 291 bytes mods/juice/textures/juice_water.png | Bin 0 -> 291 bytes mods/juice/textures/juice_water_sugar.png | Bin 0 -> 352 bytes mods/potions/init.lua | 142 ++++++++++++---------- mods/potions/init.lua~ | 142 ++++++++++++---------- mods/potions/textures/potions_black.png | Bin 0 -> 239 bytes mods/potions/textures/potions_glass.png | Bin 0 -> 241 bytes 15 files changed, 330 insertions(+), 128 deletions(-) create mode 100644 mods/juice/LICENSE.txt create mode 100644 mods/juice/depends.txt create mode 100644 mods/juice/depends.txt~ create mode 100644 mods/juice/init.lua create mode 100644 mods/juice/init.lua~ create mode 100644 mods/juice/textures/juice_apple.png create mode 100644 mods/juice/textures/juice_cactus.png create mode 100644 mods/juice/textures/juice_glass.png create mode 100644 mods/juice/textures/juice_strawberry.png create mode 100644 mods/juice/textures/juice_water.png create mode 100644 mods/juice/textures/juice_water_sugar.png create mode 100644 mods/potions/textures/potions_black.png create mode 100644 mods/potions/textures/potions_glass.png diff --git a/mods/juice/LICENSE.txt b/mods/juice/LICENSE.txt new file mode 100644 index 0000000..6f6a256 --- /dev/null +++ b/mods/juice/LICENSE.txt @@ -0,0 +1,16 @@ +License for Code +---------------- + +Copyright (C) 2016 cd2 (cdqwertz) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html + +License for Media +----------------- + +CC-BY-SA 3.0 UNPORTED. Created by cd2 (cdqwertz) diff --git a/mods/juice/depends.txt b/mods/juice/depends.txt new file mode 100644 index 0000000..d77ba25 --- /dev/null +++ b/mods/juice/depends.txt @@ -0,0 +1,2 @@ +default +farming diff --git a/mods/juice/depends.txt~ b/mods/juice/depends.txt~ new file mode 100644 index 0000000..d77ba25 --- /dev/null +++ b/mods/juice/depends.txt~ @@ -0,0 +1,2 @@ +default +farming diff --git a/mods/juice/init.lua b/mods/juice/init.lua new file mode 100644 index 0000000..31ae48b --- /dev/null +++ b/mods/juice/init.lua @@ -0,0 +1,77 @@ +juice = {} +function juice.drink(player, itemstack, hp) + player:set_hp(player:get_hp()+hp) + itemstack = {name = "juice:glass", count = 1} + return itemstack +end + +minetest.register_craftitem("juice:glass", { + description = "Glass", + inventory_image = "juice_glass.png", +}) + +minetest.register_craftitem("juice:water", { + description = "Water", + inventory_image = "juice_water.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 3) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:water_sugar", { + description = "Water with Sugar", + inventory_image = "juice_water_sugar.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, -2) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:cactus", { + description = "Cactus Juice", + inventory_image = "juice_cactus.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 6) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:strawberry", { + description = "Strawberry Juice", + inventory_image = "juice_strawberry.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 6) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:apple", { + description = "Apple Juice", + inventory_image = "juice_apple.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 7) + end, + stack_max = 1, +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:cactus", + recipe = {"juice:glass", "farming:cactus"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:water", + recipe = {"juice:glass", "farming:bowl_with_water"}, + replacements = { + {"farming:bowl_with_water", "farming:bowl"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:water_sugar", + recipe = {"juice:water", "farming:sugar"}, +}) diff --git a/mods/juice/init.lua~ b/mods/juice/init.lua~ new file mode 100644 index 0000000..31ae48b --- /dev/null +++ b/mods/juice/init.lua~ @@ -0,0 +1,77 @@ +juice = {} +function juice.drink(player, itemstack, hp) + player:set_hp(player:get_hp()+hp) + itemstack = {name = "juice:glass", count = 1} + return itemstack +end + +minetest.register_craftitem("juice:glass", { + description = "Glass", + inventory_image = "juice_glass.png", +}) + +minetest.register_craftitem("juice:water", { + description = "Water", + inventory_image = "juice_water.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 3) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:water_sugar", { + description = "Water with Sugar", + inventory_image = "juice_water_sugar.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, -2) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:cactus", { + description = "Cactus Juice", + inventory_image = "juice_cactus.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 6) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:strawberry", { + description = "Strawberry Juice", + inventory_image = "juice_strawberry.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 6) + end, + stack_max = 1, +}) + +minetest.register_craftitem("juice:apple", { + description = "Apple Juice", + inventory_image = "juice_apple.png", + on_use = function(itemstack, user, pointed_thing) + return juice.drink(user, itemstack, 7) + end, + stack_max = 1, +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:cactus", + recipe = {"juice:glass", "farming:cactus"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:water", + recipe = {"juice:glass", "farming:bowl_with_water"}, + replacements = { + {"farming:bowl_with_water", "farming:bowl"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "juice:water_sugar", + recipe = {"juice:water", "farming:sugar"}, +}) diff --git a/mods/juice/textures/juice_apple.png b/mods/juice/textures/juice_apple.png new file mode 100644 index 0000000000000000000000000000000000000000..13b10b6858a113b83014055a17b46b575370cbc4 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|>ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?Tt?>SucX}o3Q3l@MwB?`=jNv7l`uFLr6!i7 zrYMwWmSiZnd-?{1H}Z)C6?J>MIEGl9PEL@>IMCty;o@TV|AmlTe0f`6V%E~uN&}w6gK4KPZ;yY_#o4*}L6Mf3cmlHp?~czaxSf4m*YP;_aL#`= zfB(J%hI-D0yB<7Wug~))$Hw9(3vWZF63Yw?Uk~PdhHFdyyt}*me>A^%V#jT1GeN&o hKRz+%*6~^(AI4ZLKumNj#W#`ttVp2VI<E z1BQCeg}WXc@0aJ1k&&_Z$->)^sl+lv!`Fj3pW)h)Kkx4D{{Q)#SaL`EOmiW>Q$Id2 e?@C+6!0=4i>i#p;*Y|Ah{)FMvXlC9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3hti10pX2&;y^`7o-U3d7N?UFBr*C4;WA9QhcZhlatWhS1$>@$V!(F(@qgA8jtf8O0){y*QY mrqNVY$mi6LPt3d0RxvOHTPQv}!*>qkO9oF@KbLh*2~7aSDp-mD literal 0 HcmV?d00001 diff --git a/mods/juice/textures/juice_strawberry.png b/mods/juice/textures/juice_strawberry.png new file mode 100644 index 0000000000000000000000000000000000000000..a21e12c7fdaabdf1e8c3c080587493441d407d92 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|>ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?TqYvcFE{7_g(OQ{BTAg}b8}PkN*J7rQWHy3 zQxwWGOEMJPJ$(bh8~Mb6in={r978NlCnrc`9O&@7gSr2$Xk!L-wtx5q!|;_Te~ph(M1Jb~GQSK!ueUgtM+H;cDP2-}^t zzrU|FIi~GV$-(p6^CfSzwibTklw!E-!eJ0NYXaLnhBcl)@9r-DAAf#!yW%-XF*gg% g$EW#U%v#CBkm6)%J1K-$6X+}kPgg&ebxsLQ00TB>6#xJL literal 0 HcmV?d00001 diff --git a/mods/juice/textures/juice_water.png b/mods/juice/textures/juice_water.png new file mode 100644 index 0000000000000000000000000000000000000000..7335eee71d9cee1e6593170e63298a5857461c14 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|>ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?T!z{oeq@FKg(OQ{BTAg}b8}PkN*J7rQWHy3 zQxwWGOEMJPJ$(bh8~Mb6in={r978NlCnrc`9O&@7gSr2$Xk!L-wtx5q!|;_Te~ph(M1Jb~GQ_r|X0YHc&NcU!ed2-}^V zZ}-0;Ii~GV$-(94?InIxSQdQZlw!E-!eJ0NYXaLnhBcl)@9r-D|NEKT5dnX0bG12B gK0akHIUB;rAlP8_Uc+4A2hdpzp00i_>zopr0OI^ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?+*};_@8@a)g(OQ{BTAg}b8}PkN*J7rQWHy3 zQxwWGOEMJPJ$(bh8~Mb6icWaCIEGl9PEL@>IMCty;o@TV|AmlTe0f`6V%E~uN&}w6gK4KPZ;yY_#o4*}L6Mf3cmlHp?~Ps0)!Jrk@3v}_5Y{{U z?AbG(`F8&sF7Mz;J@mBcZZ)6LhmS=Db8IRn9lUx}E{`LSZN}``#s)x8^XpIZ!^_X* zd3Jx7Nhv7ZsD6)O##)01uaeGhs6Oxbh_|7VaV~GMWFXst9Jg}GK+m6dcbEVF{cO># ss!vZm+qM)WAM%upuXDKWBg(+AOe1*0m+wbPfqr7}boFyt=akR{06oWw?*IS* literal 0 HcmV?d00001 diff --git a/mods/potions/init.lua b/mods/potions/init.lua index 3047a5e..964a755 100644 --- a/mods/potions/init.lua +++ b/mods/potions/init.lua @@ -1,18 +1,29 @@ -minetest.register_craftitem("potions:healing", { - description = "Potion of Healing", - inventory_image = "potions_red.png", +potions = {} +function potions.register_potion(name, def) + minetest.register_craftitem(name, { + description = def.description, + inventory_image = def.img, on_drop = function(itemstack, dropper, pos) if not dropper or not dropper:is_player() then return end - cmsg.push_message_player(dropper, "[hp] + 10") - dropper:set_hp(dropper:get_hp()+10) - itemstack:take_item() - return itemstack + return def.on_use(itemstack, dropper) end, on_use = function(itemstack, user, pointed_thing) + if not user or not user:is_player() then + return + end + return def.on_use(itemstack, user) + end, +}) +end + +potions.register_potion("potions:healing", { + description = "Potion of Healing", + img = "potions_red.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -20,37 +31,13 @@ minetest.register_craftitem("potions:healing", { user:set_hp(user:get_hp()+10) itemstack:take_item() return itemstack - end, + end }) -minetest.register_craftitem("potions:jumping", { +potions.register_potion("potions:jumping", { description = "Potion of Jumping", - inventory_image = "potions_blue.png", - - on_drop = function(itemstack, dropper, pos) - if not dropper or not dropper:is_player() then - return - end - dropper:set_physics_override({ - gravity = 0.1, - }) - cmsg.push_message_player(dropper, "[effect] + jump") - - - minetest.after(10.0, function(pl) - if not pl or not pl:is_player() then - return - end - pl:set_physics_override({ - gravity = 1, - }) - cmsg.push_message_player(pl, "[effect] - jump") - end, dropper) - itemstack:take_item() - return itemstack - end, - - on_use = function(itemstack, user, pointed_thing) + img = "potions_blue.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -70,37 +57,13 @@ minetest.register_craftitem("potions:jumping", { end, user) itemstack:take_item() return itemstack - end, + end }) -minetest.register_craftitem("potions:running", { +potions.register_potion("potions:running", { description = "Potion of Running", - inventory_image = "potions_yellow.png", - - on_drop = function(itemstack, dropper, pos) - if not dropper or not dropper:is_player() then - return - end - dropper:set_physics_override({ - speed = 3, - }) - cmsg.push_message_player(dropper, "[effect] + speed") - - - minetest.after(10.0, function(pl) - if not pl or not pl:is_player() then - return - end - pl:set_physics_override({ - speed = 1, - }) - cmsg.push_message_player(pl, "[effect] - speed") - end, dropper) - itemstack:take_item() - return itemstack - end, - - on_use = function(itemstack, user, pointed_thing) + img = "potions_yellow.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -120,10 +83,61 @@ minetest.register_craftitem("potions:running", { end, user) itemstack:take_item() return itemstack - end, + end +}) + +minetest.register_craftitem("potions:strange", { + description = "strange Potion", + inventory_image = "potions_black.png", +}) + +minetest.register_craftitem("potions:glass", { + description = "Glass", + inventory_image = "potions_glass.png", }) minetest.register_craftitem("potions:upgrading", { description = "Potion of Upgrading", inventory_image = "potions_green.png", }) + +-- crafting + +minetest.register_craft({ + type = "shapeless", + output = "potions:strange", + recipe = {"potions:glass", "juice:cactus", "juice:cactus", "juice:water"}, + replacements = { + {"juice:cactus", "juice:glass"}, + {"juice:cactus", "juice:glass"}, + {"juice:water", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:running", + recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water_sugar", "potions:glass"}, + replacements = { + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:jumping", + recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water", "potions:glass"}, + replacements = { + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"}, + {"juice:water", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:upgrading", + recipe = {"potions:strange", "default:stone_item", "farming:cactus", "default:sand"}, +}) diff --git a/mods/potions/init.lua~ b/mods/potions/init.lua~ index 3047a5e..964a755 100644 --- a/mods/potions/init.lua~ +++ b/mods/potions/init.lua~ @@ -1,18 +1,29 @@ -minetest.register_craftitem("potions:healing", { - description = "Potion of Healing", - inventory_image = "potions_red.png", +potions = {} +function potions.register_potion(name, def) + minetest.register_craftitem(name, { + description = def.description, + inventory_image = def.img, on_drop = function(itemstack, dropper, pos) if not dropper or not dropper:is_player() then return end - cmsg.push_message_player(dropper, "[hp] + 10") - dropper:set_hp(dropper:get_hp()+10) - itemstack:take_item() - return itemstack + return def.on_use(itemstack, dropper) end, on_use = function(itemstack, user, pointed_thing) + if not user or not user:is_player() then + return + end + return def.on_use(itemstack, user) + end, +}) +end + +potions.register_potion("potions:healing", { + description = "Potion of Healing", + img = "potions_red.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -20,37 +31,13 @@ minetest.register_craftitem("potions:healing", { user:set_hp(user:get_hp()+10) itemstack:take_item() return itemstack - end, + end }) -minetest.register_craftitem("potions:jumping", { +potions.register_potion("potions:jumping", { description = "Potion of Jumping", - inventory_image = "potions_blue.png", - - on_drop = function(itemstack, dropper, pos) - if not dropper or not dropper:is_player() then - return - end - dropper:set_physics_override({ - gravity = 0.1, - }) - cmsg.push_message_player(dropper, "[effect] + jump") - - - minetest.after(10.0, function(pl) - if not pl or not pl:is_player() then - return - end - pl:set_physics_override({ - gravity = 1, - }) - cmsg.push_message_player(pl, "[effect] - jump") - end, dropper) - itemstack:take_item() - return itemstack - end, - - on_use = function(itemstack, user, pointed_thing) + img = "potions_blue.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -70,37 +57,13 @@ minetest.register_craftitem("potions:jumping", { end, user) itemstack:take_item() return itemstack - end, + end }) -minetest.register_craftitem("potions:running", { +potions.register_potion("potions:running", { description = "Potion of Running", - inventory_image = "potions_yellow.png", - - on_drop = function(itemstack, dropper, pos) - if not dropper or not dropper:is_player() then - return - end - dropper:set_physics_override({ - speed = 3, - }) - cmsg.push_message_player(dropper, "[effect] + speed") - - - minetest.after(10.0, function(pl) - if not pl or not pl:is_player() then - return - end - pl:set_physics_override({ - speed = 1, - }) - cmsg.push_message_player(pl, "[effect] - speed") - end, dropper) - itemstack:take_item() - return itemstack - end, - - on_use = function(itemstack, user, pointed_thing) + img = "potions_yellow.png", + on_use = function(itemstack, user) if not user or not user:is_player() then return end @@ -120,10 +83,61 @@ minetest.register_craftitem("potions:running", { end, user) itemstack:take_item() return itemstack - end, + end +}) + +minetest.register_craftitem("potions:strange", { + description = "strange Potion", + inventory_image = "potions_black.png", +}) + +minetest.register_craftitem("potions:glass", { + description = "Glass", + inventory_image = "potions_glass.png", }) minetest.register_craftitem("potions:upgrading", { description = "Potion of Upgrading", inventory_image = "potions_green.png", }) + +-- crafting + +minetest.register_craft({ + type = "shapeless", + output = "potions:strange", + recipe = {"potions:glass", "juice:cactus", "juice:cactus", "juice:water"}, + replacements = { + {"juice:cactus", "juice:glass"}, + {"juice:cactus", "juice:glass"}, + {"juice:water", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:running", + recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water_sugar", "potions:glass"}, + replacements = { + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:jumping", + recipe = {"juice:water_sugar", "juice:water_sugar", "juice:water", "potions:glass"}, + replacements = { + {"juice:water_sugar", "juice:glass"}, + {"juice:water_sugar", "juice:glass"}, + {"juice:water", "juice:glass"} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "potions:upgrading", + recipe = {"potions:strange", "default:stone_item", "farming:cactus", "default:sand"}, +}) diff --git a/mods/potions/textures/potions_black.png b/mods/potions/textures/potions_black.png new file mode 100644 index 0000000000000000000000000000000000000000..dce196b8e718371ad3ea4db930fcdf67669f519e GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|>ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?-293GS|5QT43Z_T5hc#~xw)x%B@E6*sfi`2 zDGKG8B^e6tp1uL$jeO!jMd6+wYzWz`7@(u>!rDD8$7<+d7vCq9_ z!UhCw)Ai$xOw7!TGBPs_g;E)IrAZt}Lm$ Z!OZZ^QHQ5-L2WL`A)c;&F6*2UngAA*L)8EP literal 0 HcmV?d00001 diff --git a/mods/potions/textures/potions_glass.png b/mods/potions/textures/potions_glass.png new file mode 100644 index 0000000000000000000000000000000000000000..e6e5759cf77100687b1a5714a78a931a9df792ac GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|>ks~HlL&ay5Bif|Tq zL>4nJa0`PlBg3pY5H=O_6JO?+`JZS<A;}Wgh!W@g+}zZ>5(ej@)Wnk1 z6ovB4k_-iRPv3y>Mm}+%qDW5{#}JFt$q5py76-RxU;n3kc?W~=QZe2=j6FO4oZpl! zuFTBLe0cfy_mVpf9sZx4nQ17L%CIX<;y@~gpT0u2nibE4TzB^SVe3+kh%N2e@kn0! ffGD4{3^Yn>&YylIDlmN0m_`njxgN@xNAVF*U* literal 0 HcmV?d00001