formatting and minetest -> core
This commit is contained in:
parent
52ae408d4a
commit
ab71007d3a
10
README.md
10
README.md
|
@ -1,5 +1,9 @@
|
||||||
[![ContentDB](https://content.minetest.net/packages/cool_beans/moth/shields/downloads/)](https://content.minetest.net/packages/cool_beans/moth/)
|
[![ContentDB](https://content.minetest.net/packages/cool_beans/moth/shields/downloads/)](https://content.minetest.net/packages/cool_beans/moth/)
|
||||||
|
|
||||||
# Moth
|
# Moth
|
||||||
<p> A simple mod for minetest which adds moths that can send messages (like in Lord of the Rings). </p>
|
|
||||||
<p> Use a white dandilion to summon a moth, and use a moth to send a message. </p>
|
A simple mod for minetest which adds moths that can send messages (like in Lord of the Rings).
|
||||||
<p> Unfortunatly, there isn't giant eagles to call for to save you from Isengard! </p>
|
|
||||||
|
Use a white dandilion to summon a moth, and use a moth to send a message.
|
||||||
|
|
||||||
|
Unfortunatly, there isn't giant eagles to call for to save you from Isengard!
|
||||||
|
|
35
init.lua
35
init.lua
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
local function get_moth_formspec()
|
local function get_moth_formspec()
|
||||||
return "size[10,10]"..
|
return "size[10,10]"
|
||||||
"field[1,1;8,1;target;Recipent: ;name]"..
|
.. "field[1,1;8,1;target;Recipent: ;name]"
|
||||||
"textarea[1,3;8,5;message;Message: ;Help me!]"..
|
.. "textarea[1,3;8,5;message;Message: ;Help me!]"
|
||||||
"button_exit[1,8;5,1;send;Fly Away...]"
|
.. "button_exit[1,8;5,1;send;Fly Away...]"
|
||||||
end
|
end
|
||||||
minetest.register_node("moth:moth", {
|
|
||||||
|
core.register_node("moth:moth", {
|
||||||
description = "Moth",
|
description = "Moth",
|
||||||
inventory_image = "moth_img.png",
|
inventory_image = "moth_img.png",
|
||||||
wield_image = "moth_img.png",
|
wield_image = "moth_img.png",
|
||||||
|
@ -17,25 +19,32 @@ minetest.register_node("moth:moth", {
|
||||||
animation = { type="vertical_frames", aspect_w=16, aspect_h=16, length=1 }
|
animation = { type="vertical_frames", aspect_w=16, aspect_h=16, length=1 }
|
||||||
}},
|
}},
|
||||||
groups = { oddly_breakable_by_hand=3 },
|
groups = { oddly_breakable_by_hand=3 },
|
||||||
|
|
||||||
on_use = function(itemstack, player, pointed_thing)
|
on_use = function(itemstack, player, pointed_thing)
|
||||||
minetest.show_formspec(player:get_player_name(), "moth_send", get_moth_formspec())
|
core.show_formspec(player:get_player_name(), "moth_send", get_moth_formspec())
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
||||||
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "moth_send" then
|
if formname == "moth_send" then
|
||||||
if fields.send then
|
if fields.send then
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
inv:remove_item("main", "moth:moth")
|
inv:remove_item("main", "moth:moth")
|
||||||
local rec = minetest.get_player_by_name(fields.target)
|
local rec = core.get_player_by_name(fields.target)
|
||||||
if rec then
|
if rec then
|
||||||
local pos = rec:get_pos()
|
local pos = rec:get_pos()
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
minetest.set_node(pos, {name = "moth:moth"})
|
core.set_node(pos, { name="moth:moth" })
|
||||||
minetest.show_formspec(rec:get_player_name(), "moth_show", "size[10,10]".."label[0.5,0.5;A moth whispers to you...]".."label[0.5,1;(From "..minetest.formspec_escape(player:get_player_name())..")".."]".."textarea[0.5,2.5;7.5,7;;" ..minetest.formspec_escape(fields.message) .. ";]")
|
core.show_formspec(rec:get_player_name(), "moth_show", "size[10,10]".."label[0.5,0.5;A moth whispers to you...]".."label[0.5,1;(From "..core.formspec_escape(player:get_player_name())..")".."]".."textarea[0.5,2.5;7.5,7;;" ..core.formspec_escape(fields.message) .. ";]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if minetest.get_modpath("flowers") then
|
|
||||||
minetest.override_item("flowers:dandelion_white", {on_use = function(itemstack, player, pointed_thing) minetest.set_node(player:get_pos(), {name = "moth:moth"}) end})
|
if core.get_modpath("flowers") then
|
||||||
|
core.override_item("flowers:dandelion_white", {
|
||||||
|
on_use = function(itemstack, player, pointed_thing)
|
||||||
|
core.set_node(player:get_pos(), { name="moth:moth" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue