added juice and potions code cleanup
16
mods/juice/LICENSE.txt
Normal file
@ -0,0 +1,16 @@
|
||||
License for Code
|
||||
----------------
|
||||
|
||||
Copyright (C) 2016 cd2 (cdqwertz) <cdqwertz@gmail.com>
|
||||
|
||||
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)
|
2
mods/juice/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
default
|
||||
farming
|
2
mods/juice/depends.txt~
Normal file
@ -0,0 +1,2 @@
|
||||
default
|
||||
farming
|
77
mods/juice/init.lua
Normal file
@ -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"},
|
||||
})
|
77
mods/juice/init.lua~
Normal file
@ -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"},
|
||||
})
|
BIN
mods/juice/textures/juice_apple.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
mods/juice/textures/juice_cactus.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
mods/juice/textures/juice_glass.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
mods/juice/textures/juice_strawberry.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
mods/juice/textures/juice_water.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
mods/juice/textures/juice_water_sugar.png
Normal file
After Width: | Height: | Size: 352 B |
@ -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"},
|
||||
})
|
||||
|
@ -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"},
|
||||
})
|
||||
|
BIN
mods/potions/textures/potions_black.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
mods/potions/textures/potions_glass.png
Normal file
After Width: | Height: | Size: 241 B |