forked from Sokomine/yl_speak_up
moved edit_mode out of functions.lua
This commit is contained in:
parent
21005455ab
commit
763a7e27c5
@ -9,6 +9,15 @@
|
||||
-- -> ends edit mode
|
||||
-- (happens in fs/fs_talkdialog_in_edit_mode.lua)
|
||||
|
||||
|
||||
-- store if the player is editing a particular NPC; format: yl_speak_up.edit_mode[pname] = npc_id
|
||||
yl_speak_up.edit_mode = {}
|
||||
|
||||
-- changes applied in edit_mode are applied immediately - but not immediately stored to disk
|
||||
-- (this gives the players a chance to back off in case of unwanted changes)
|
||||
yl_speak_up.npc_was_changed = {}
|
||||
|
||||
|
||||
-- is the player in edit mode?
|
||||
yl_speak_up.in_edit_mode = function(pname)
|
||||
return pname
|
||||
@ -16,6 +25,26 @@ yl_speak_up.in_edit_mode = function(pname)
|
||||
and (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)
|
||||
end
|
||||
|
||||
|
||||
-- reset edit_mode when stopping to talk to an NPC
|
||||
local old_reset_vars_for_player = yl_speak_up.reset_vars_for_player
|
||||
yl_speak_up.reset_vars_for_player = function(pname, reset_fs_version)
|
||||
yl_speak_up.edit_mode[pname] = nil
|
||||
old_reset_vars_for_player(pname, reset_fs_version)
|
||||
end
|
||||
|
||||
|
||||
-- make sure generic dialogs are never included in edit_mode (because in edit mode we want to
|
||||
-- edit this particular NPC without generic parts)
|
||||
local old_load_dialog = yl_speak_up.load_dialog
|
||||
yl_speak_up.load_dialog = function(n_id, player) -- returns the saved dialog
|
||||
if(player and yl_speak_up.in_edit_mode(player:get_player_name())) then
|
||||
return old_load_dialog(n_id, false)
|
||||
end
|
||||
return old_load_dialog(n_id, player)
|
||||
end
|
||||
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
-- TODO: adjust to new mod name and paths
|
||||
|
@ -2,12 +2,9 @@
|
||||
-- Init
|
||||
--###
|
||||
|
||||
-- store if the player is editing a particular NPC; format: yl_speak_up.edit_mode[pname] = npc_id
|
||||
yl_speak_up.edit_mode = {}
|
||||
|
||||
-- changes applied in edit_mode are applied immediately - but not immediately stored to disk
|
||||
-- (this gives the players a chance to back off in case of unwanted changes)
|
||||
yl_speak_up.npc_was_changed = {}
|
||||
-- TODO yl_speak_up.npc_was_changed = {}
|
||||
|
||||
-- self (the npc as such) is rarely passed on to any functions; in order to be able to check if
|
||||
-- the player really owns the npc, we need to have that data available;
|
||||
@ -22,7 +19,6 @@ yl_speak_up.last_text_input = {}
|
||||
|
||||
yl_speak_up.reset_vars_for_player = function(pname, reset_fs_version)
|
||||
yl_speak_up.speak_to[pname] = nil
|
||||
yl_speak_up.edit_mode[pname] = nil
|
||||
yl_speak_up.last_text_input[pname] = nil
|
||||
-- when just stopping editing: don't reset the fs_version
|
||||
if(reset_fs_version) then
|
||||
@ -608,13 +604,7 @@ function yl_speak_up.talk(self, clicker)
|
||||
yl_speak_up.speak_to[pname].obj = self.object
|
||||
-- Load the dialog and see what we can do with it
|
||||
-- this inculdes generic dialog parts;
|
||||
-- make sure this is never true in edit mode (because in edit mode we want to
|
||||
-- edit this particular NPC without generic parts)
|
||||
local player = clicker
|
||||
if(yl_speak_up.edit_mode[pname] == n_id) then
|
||||
player = false
|
||||
end
|
||||
yl_speak_up.speak_to[pname].dialog = yl_speak_up.load_dialog(n_id, player)
|
||||
yl_speak_up.speak_to[pname].dialog = yl_speak_up.load_dialog(n_id, clicker)
|
||||
|
||||
-- is this player explicitly allowed to edit this npc?
|
||||
if(yl_speak_up.speak_to[pname].dialog
|
||||
|
Loading…
Reference in New Issue
Block a user