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
end
---------------------------------------------------------------------
-- Returns a random chatline for unimportant NPCs
---------------------------------------------------------------------
local function get_random_chatline(chat_options)
local chat_options_length = table.getn(chat_options)
local random_option = math.random(1, chat_options_length - 1)
local found = false
while found == false do
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
-- New function for getting dialogue formspec
local l = smartfs.create("smartfs:load", function(state)
state:load(minetest.get_modpath("smartfs").."/docs/example.smartfs")
state:get("btn"):click(function(self,state)
print("Button clicked!")
end)
return true
end)
---------------------------------------------------------------------
-- Returns all chatlines for a specific NPC

View File

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

1005
lib/smartfs.lua Normal file

File diff suppressed because it is too large Load Diff