mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-11-04 14:23:10 +01:00
add buttons to make npc follow, stand or wander
This commit is contained in:
parent
f3be11f647
commit
aec252c323
@ -28,6 +28,24 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
local new_move_order = ""
|
||||
if(fields.order_stand) then
|
||||
new_move_order = "stand"
|
||||
elseif(fields.order_follow) then
|
||||
new_move_order = "follow"
|
||||
elseif(fields.order_wander) then
|
||||
new_move_order = "wander"
|
||||
end
|
||||
if(new_move_order ~= "") then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
yl_speak_up.set_npc_property(pname, "self.order", new_move_order)
|
||||
minetest.chat_send_player(pname,
|
||||
tostring(dialog.n_npc or "NPC").." tells you: "..
|
||||
"Ok. I will "..tostring(new_move_order)..".")
|
||||
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)
|
||||
|
||||
@ -106,7 +124,7 @@ yl_speak_up.input_talk = function(player, formname, fields)
|
||||
-- if there are any changes done: ask first and don't end edit mode yet
|
||||
yl_speak_up.show_fs(player, "quit", nil)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if fields.quit or fields.button_exit then
|
||||
-- if there are any changes done: ask first and don't quit yet
|
||||
@ -662,7 +680,15 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
(edit_mode or dialog.n_dialogs["d_got_item"]), nil, nil, pname_for_old_fs)
|
||||
end
|
||||
|
||||
-- can the player edit this NPC?
|
||||
local may_edit_npc = yl_speak_up.may_edit_npc(player, n_id)
|
||||
-- for muting and for checking the owner/order, the luaentity is needed
|
||||
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 in edit mode, add new menu entries: "add new options", "end edit mode" and what else is needed.
|
||||
if(edit_mode) then
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
@ -723,12 +749,6 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
"trade etc. are shown.", nil, pname_for_old_fs)
|
||||
|
||||
-- chat option: Mute/Unmute NPC
|
||||
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
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"mute_npc",
|
||||
-- chat option: mute the NPC
|
||||
@ -794,6 +814,28 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
true, nil, nil, pname_for_old_fs)
|
||||
end
|
||||
|
||||
if(luaentity and luaentity.order and may_edit_npc) then
|
||||
if(luaentity.order ~= "follow") then
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"order_follow",
|
||||
"The NPC will follow you.",
|
||||
"New order: Follow me!",
|
||||
((luaentity.owner == pname) and (luaentity.order ~= "follow")),
|
||||
"New order: Follow me. (Only available for owner).",
|
||||
nil, pname_for_old_fs)
|
||||
end
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"order_stand",
|
||||
"The NPC will wait here.",
|
||||
"New order: Stand here.",
|
||||
(luaentity.order ~= "stand"), nil, nil, pname_for_old_fs)
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"order_wander",
|
||||
"The NPC will wander around randomly.",
|
||||
"New order: Wander around a bit on your own.",
|
||||
(luaentity.order ~= "walking"), 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