diff --git a/mods/quests/depends.txt b/mods/quests/depends.txt index 07f8b9f..355f0a1 100644 --- a/mods/quests/depends.txt +++ b/mods/quests/depends.txt @@ -1,2 +1,3 @@ default central_message +story diff --git a/mods/quests/depends.txt~ b/mods/quests/depends.txt~ index 07f8b9f..355f0a1 100644 --- a/mods/quests/depends.txt~ +++ b/mods/quests/depends.txt~ @@ -1,2 +1,3 @@ default central_message +story diff --git a/mods/story/api.lua b/mods/story/api.lua index 77df8ba..005615d 100644 --- a/mods/story/api.lua +++ b/mods/story/api.lua @@ -2,5 +2,13 @@ story.talk_form = "size[8,7.5;]" story.talk_form = story.talk_form..default.gui_colors story.talk_form = story.talk_form..default.gui_bg story.talk_form = story.talk_form.."image[0,0.0;3,8;story_player.png]" -story.talk_form = story.talk_form.."label[2.5,0;You : Hi\nCate : Hi, I have an quest for you!]" +story.talk_form = story.talk_form.."label[2.5,0;%s]" story.talk_form = story.talk_form.."image[6,0.0;3,8;story_character_1.png]" + +story.set_talk_form = function(pos, name, text) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", string.format(story.talk_form, text)) + meta:set_string("infotext", name) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) +end diff --git a/mods/story/api.lua~ b/mods/story/api.lua~ index 77df8ba..005615d 100644 --- a/mods/story/api.lua~ +++ b/mods/story/api.lua~ @@ -2,5 +2,13 @@ story.talk_form = "size[8,7.5;]" story.talk_form = story.talk_form..default.gui_colors story.talk_form = story.talk_form..default.gui_bg story.talk_form = story.talk_form.."image[0,0.0;3,8;story_player.png]" -story.talk_form = story.talk_form.."label[2.5,0;You : Hi\nCate : Hi, I have an quest for you!]" +story.talk_form = story.talk_form.."label[2.5,0;%s]" story.talk_form = story.talk_form.."image[6,0.0;3,8;story_character_1.png]" + +story.set_talk_form = function(pos, name, text) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", string.format(story.talk_form, text)) + meta:set_string("infotext", name) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) +end diff --git a/mods/story/init.lua b/mods/story/init.lua index 5d77c90..a0e17d8 100644 --- a/mods/story/init.lua +++ b/mods/story/init.lua @@ -8,15 +8,28 @@ minetest.register_node("story:character_static", { tiles = {"character.png"}, drawtype = "mesh", mesh = "character_static.obj", - groups = {crumbly = 3}, + groups = {story = 1, quests =1}, paramtype = "light", paramtype2 = "facedir", on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", story.talk_form) - meta:set_string("infotext", "Character") - local inv = meta:get_inventory() - inv:set_size("main", 8*4) + story.set_talk_form(pos, "Character", "") + end, + +}) + +minetest.register_craftitem("story:conversation", { + description = "Set Conversation", + inventory_image = "story_set_conversation.png", + on_place = function(itemstack, placer, pointed_thing) + if not placer or not placer:is_player() then + return + end + if not pointed_thing or not pointed_thing.under then + return + end + story.set_talk_form(pointed_thing.under) end, }) + + diff --git a/mods/story/init.lua~ b/mods/story/init.lua~ index 5d77c90..a0e17d8 100644 --- a/mods/story/init.lua~ +++ b/mods/story/init.lua~ @@ -8,15 +8,28 @@ minetest.register_node("story:character_static", { tiles = {"character.png"}, drawtype = "mesh", mesh = "character_static.obj", - groups = {crumbly = 3}, + groups = {story = 1, quests =1}, paramtype = "light", paramtype2 = "facedir", on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", story.talk_form) - meta:set_string("infotext", "Character") - local inv = meta:get_inventory() - inv:set_size("main", 8*4) + story.set_talk_form(pos, "Character", "") + end, + +}) + +minetest.register_craftitem("story:conversation", { + description = "Set Conversation", + inventory_image = "story_set_conversation.png", + on_place = function(itemstack, placer, pointed_thing) + if not placer or not placer:is_player() then + return + end + if not pointed_thing or not pointed_thing.under then + return + end + story.set_talk_form(pointed_thing.under) end, }) + + diff --git a/mods/story/textures/story_set_conversation.png b/mods/story/textures/story_set_conversation.png new file mode 100644 index 0000000..7f53666 Binary files /dev/null and b/mods/story/textures/story_set_conversation.png differ