added yl_speak_up.add_on_rightclick_entry for picking up mobs
This commit is contained in:
parent
28a1fc8b9a
commit
e69e2f4c02
@ -83,6 +83,14 @@ yl_speak_up.mob_capes = {}
|
||||
-- this list
|
||||
yl_speak_up.emulate_orders_on_rightclick = {}
|
||||
|
||||
-- add a special line for a particluar mob (i.e. picking mob up via menu entry
|
||||
-- instead of lasso)
|
||||
-- index: entity name; values: table with indices...
|
||||
-- condition a condition (i.e. a function)
|
||||
-- text_if_true text shown on button if the condition is true
|
||||
-- text_if_false text shown on button if the condition is false
|
||||
-- execute_function function to call when this button is selected
|
||||
yl_speak_up.add_on_rightclick_entry = {}
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Extend this in your own mod or i.e. in npc_talk
|
||||
|
@ -56,6 +56,22 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
-- useful for i.e. picking up the mob
|
||||
if(fields.order_custom) then
|
||||
local obj = yl_speak_up.speak_to[pname].obj
|
||||
-- some precautions - someone else might have eliminated the NPC in the meantime
|
||||
local luaentity = nil
|
||||
if(obj) then
|
||||
luaentity = obj:get_luaentity()
|
||||
end
|
||||
if(luaentity and luaentity.name and yl_speak_up.add_on_rightclick_entry[luaentity.name]) then
|
||||
local m = yl_speak_up.add_on_rightclick_entry[luaentity.name]
|
||||
local ret = m.execute_function(luaentity, player)
|
||||
end
|
||||
yl_speak_up.stop_talking(pname)
|
||||
return
|
||||
end
|
||||
|
||||
-- Is the player working on this particular npc?
|
||||
local edit_mode = (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)
|
||||
|
||||
@ -1064,6 +1080,17 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
(luaentity.order ~= "walking"), nil, nil, pname_for_old_fs)
|
||||
end
|
||||
|
||||
-- some mobs may need additional things in on_rightclick (i.e. beeing picked up)
|
||||
if(luaentity and may_edit_npc
|
||||
and yl_speak_up.add_on_rightclick_entry[luaentity.name]) then
|
||||
local m = yl_speak_up.add_on_rightclick_entry[luaentity.name]
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"order_custom",
|
||||
minetest.formspec_escape(m.text_if_false),
|
||||
minetest.formspec_escape(m.text_if_true),
|
||||
(m.condition), nil, nil, pname_for_old_fs)
|
||||
end
|
||||
|
||||
-- we are finished with adding buttons to the bottom of the formspec
|
||||
local bottom_window_fs = table.concat(formspec, "\n")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user