nlist: add .nltodf command
Dragonfire's register_list_command is terribly tedious to use. This copies an nlist to a dragonfire list. e.g. .nltodf xray_nodes/search_nodes/eject that will copy your currently selected nlist.
This commit is contained in:
parent
08213f3c17
commit
f56aac926f
@ -8,14 +8,16 @@ local mode=1 --1:add, 2:remove
|
|||||||
local nled_hud
|
local nled_hud
|
||||||
local edmode_wason=false
|
local edmode_wason=false
|
||||||
nlist.selected=sl
|
nlist.selected=sl
|
||||||
minetest.register_globalstep(function()
|
|
||||||
if not minetest.settings:get_bool('nlist_edmode') then
|
local modname = minetest.get_current_modname()
|
||||||
if (edmode_wason) then edmode_wason=false nlist.hide() end
|
local modpath = minetest.get_modpath(modname)
|
||||||
return
|
dofile(modpath .. "/forms.lua")
|
||||||
end
|
minetest.register_cheat('Lists','nList',function()ws.display_list_formspec("NodeLists",nlist.get_lists(),{}) end)
|
||||||
edmode_wason=true
|
|
||||||
nlist.show_list(sl,true)
|
ws.rg('NlEdMode','nList','nlist_edmode', function()nlist.show_list(sl,true) end,function() end,function()nlist.hide() end)
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(p, n)
|
minetest.register_on_punchnode(function(p, n)
|
||||||
if not minetest.settings:get_bool('nlist_edmode') then return end
|
if not minetest.settings:get_bool('nlist_edmode') then return end
|
||||||
@ -55,6 +57,26 @@ function nlist.get(list)
|
|||||||
if not arr then arr={} end
|
if not arr then arr={} end
|
||||||
return arr
|
return arr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function nlist.get_lists()
|
||||||
|
local ret={}
|
||||||
|
for name, _ in pairs(storage:to_table().fields) do
|
||||||
|
table.insert(ret, name)
|
||||||
|
end
|
||||||
|
table.sort(ret)
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
function nlist.rename(oldname, newname)
|
||||||
|
oldname, newname = tostring(oldname), tostring(newname)
|
||||||
|
local list = storage:get_string(oldname)
|
||||||
|
if not list or not storage:set_string(newname,list)then return end
|
||||||
|
if oldname ~= newname then
|
||||||
|
storage:set_string(list,'')
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function nlist.clear(list)
|
function nlist.clear(list)
|
||||||
storage:set_string(list,'')
|
storage:set_string(list,'')
|
||||||
end
|
end
|
||||||
@ -113,13 +135,21 @@ function set_nled_hud(ttext)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function todflist(list)
|
||||||
|
--if not minetest.settings:get(list) then return end
|
||||||
|
minetest.settings:set(list,table.concat(nlist.get(nlist.selected),","))
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand('nls',{func=function(list) sl=list nlist.selected=list end})
|
minetest.register_chatcommand('nls',{func=function(list) sl=list nlist.selected=list end})
|
||||||
minetest.register_chatcommand('nlshow',{func=function() nlist.show_list(sl) end})
|
minetest.register_chatcommand('nlshow',{func=function() nlist.show_list(sl) end})
|
||||||
minetest.register_chatcommand('nla',{func=function(el) nlist.add(sl,el) end})
|
minetest.register_chatcommand('nla',{func=function(el) nlist.add(sl,el) end})
|
||||||
minetest.register_chatcommand('nlr',{func=function(el) nlist.remove(sl,el) end})
|
minetest.register_chatcommand('nlr',{func=function(el) nlist.remove(sl,el) end})
|
||||||
minetest.register_chatcommand('nlc',{func=function(el) nlist.clear(sl) end})
|
minetest.register_chatcommand('nlc',{func=function(el) nlist.clear(sl) end})
|
||||||
|
|
||||||
minetest.register_cheat("nlEdMode","Player","nlist_edmode")
|
minetest.register_chatcommand('nlawi',{func=function() nlist.add(sl,minetest.localplayer:get_wielded_item():get_name()) end})
|
||||||
|
minetest.register_chatcommand('nlrwi',{func=function() nlist.remove(sl,minetest.localplayer:get_wielded_item():get_name()) end})
|
||||||
|
|
||||||
|
minetest.register_chatcommand('nltodf',{func=function(p) todflist(tostring(p)) end})
|
||||||
|
|
||||||
function nlist.get_mtnodes()
|
function nlist.get_mtnodes()
|
||||||
local arr= {
|
local arr= {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user