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 0000000..13b10b6 Binary files /dev/null and b/mods/juice/textures/juice_apple.png differ diff --git a/mods/juice/textures/juice_cactus.png b/mods/juice/textures/juice_cactus.png new file mode 100644 index 0000000..ad1ccac Binary files /dev/null and b/mods/juice/textures/juice_cactus.png differ diff --git a/mods/juice/textures/juice_glass.png b/mods/juice/textures/juice_glass.png new file mode 100644 index 0000000..e6e2d99 Binary files /dev/null and b/mods/juice/textures/juice_glass.png differ diff --git a/mods/juice/textures/juice_strawberry.png b/mods/juice/textures/juice_strawberry.png new file mode 100644 index 0000000..a21e12c Binary files /dev/null and b/mods/juice/textures/juice_strawberry.png differ diff --git a/mods/juice/textures/juice_water.png b/mods/juice/textures/juice_water.png new file mode 100644 index 0000000..7335eee Binary files /dev/null and b/mods/juice/textures/juice_water.png differ diff --git a/mods/juice/textures/juice_water_sugar.png b/mods/juice/textures/juice_water_sugar.png new file mode 100644 index 0000000..3fda8f2 Binary files /dev/null and b/mods/juice/textures/juice_water_sugar.png differ 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 0000000..dce196b Binary files /dev/null and b/mods/potions/textures/potions_black.png differ diff --git a/mods/potions/textures/potions_glass.png b/mods/potions/textures/potions_glass.png new file mode 100644 index 0000000..e6e5759 Binary files /dev/null and b/mods/potions/textures/potions_glass.png differ