Chat: started working on dialogue formspec.

Added smartfs for formspec functionality as library:
This commit is contained in:
zorman2000 2016-11-29 04:27:07 -05:00
parent 00e6531f91
commit f53abf7072
3 changed files with 1018 additions and 17 deletions

View File

@ -44,22 +44,14 @@ local function create_formspec(options, close_option)
return formspec return formspec
end end
--------------------------------------------------------------------- -- New function for getting dialogue formspec
-- Returns a random chatline for unimportant NPCs local l = smartfs.create("smartfs:load", function(state)
--------------------------------------------------------------------- state:load(minetest.get_modpath("smartfs").."/docs/example.smartfs")
local function get_random_chatline(chat_options) state:get("btn"):click(function(self,state)
local chat_options_length = table.getn(chat_options) print("Button clicked!")
local random_option = math.random(1, chat_options_length - 1) end)
local found = false return true
while found == false do end)
for i,chatline in ipairs(chat_options) do
if i == random_option and chatline.name == nil then
found = true
return chatline
end
end
end
end
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- Returns all chatlines for a specific NPC -- Returns all chatlines for a specific NPC

View File

@ -1,6 +1,9 @@
local path = minetest.get_modpath("advanced_npc") local path = minetest.get_modpath("advanced_npc")
-- Load SmartFS library by rubenwardy
dofile(path .. "lib/smartfs.lua")
-- Intllib -- Intllib
local S local S
if minetest.get_modpath("intllib") then if minetest.get_modpath("intllib") then
@ -24,7 +27,8 @@ end
mobs.intllib = S mobs.intllib = S
-- NPC -- NPC
dofile(path .. "/npc.lua") -- TenPlus1 dofile(path .. "/npc.lua")
dofile(path .. "/chat.lua")
--dofile(path .. "/trader.lua") --dofile(path .. "/trader.lua")
print (S("[MOD] Advanced NPC loaded")) print (S("[MOD] Advanced NPC loaded"))

1005
lib/smartfs.lua Normal file

File diff suppressed because it is too large Load Diff