forked from your-land-mirror/yl_speak_up
		
	added preconditions true and false
This commit is contained in:
		
							parent
							
								
									2435732db2
								
							
						
					
					
						commit
						e803837259
					
				| @ -86,6 +86,12 @@ yl_speak_up.eval_precondition = function(player, n_id, p, other_options_true_or_ | |||||||
| 	elseif(p.p_type == "auto") then | 	elseif(p.p_type == "auto") then | ||||||
| 		-- a precondition set by using the staff; kept for compatibility | 		-- a precondition set by using the staff; kept for compatibility | ||||||
| 		return true | 		return true | ||||||
|  | 	elseif(p.p_type == "true") then | ||||||
|  | 		-- mostly useful for generic dialogs | ||||||
|  | 		return true | ||||||
|  | 	elseif(p.p_type == "false") then | ||||||
|  | 		-- mostly useful for temporally disabling options | ||||||
|  | 		return false | ||||||
| 	elseif(p.p_type == "function") then | 	elseif(p.p_type == "function") then | ||||||
| 		if(not(yl_speak_up.npc_has_priv(n_id, "precon_exec_lua", p.p_is_generic))) then | 		if(not(yl_speak_up.npc_has_priv(n_id, "precon_exec_lua", p.p_is_generic))) then | ||||||
| 			return false | 			return false | ||||||
|  | |||||||
| @ -755,6 +755,11 @@ yl_speak_up.save_element_p_or_a_or_e = function( | |||||||
| 		if(data.fulfilled  and data.fulfilled  ~= "-select-") then | 		if(data.fulfilled  and data.fulfilled  ~= "-select-") then | ||||||
| 			v[ "p_fulfilled" ] = data.fulfilled | 			v[ "p_fulfilled" ] = data.fulfilled | ||||||
| 		end | 		end | ||||||
|  | 
 | ||||||
|  | 	elseif(what_type == "true") then | ||||||
|  | 		v[ "p_value" ] = true -- doesn't matter here - just *some* value | ||||||
|  | 	elseif(what_type == "false") then | ||||||
|  | 		v[ "p_value" ] = true -- doesn't matter here - just *some* value | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	v[ "alternate_text" ] = data.alternate_text | 	v[ "alternate_text" ] = data.alternate_text | ||||||
|  | |||||||
| @ -71,6 +71,8 @@ local check_what = { | |||||||
| 	"execute Lua code (requires npc_master priv)", -- 7 -> 9 | 	"execute Lua code (requires npc_master priv)", -- 7 -> 9 | ||||||
| 	"Call custom functions that are supposed to be overridden by the server.", -- 8 -> 10 | 	"Call custom functions that are supposed to be overridden by the server.", -- 8 -> 10 | ||||||
| 	"The preconditions of another dialog option are fulfilled/not fulfilled.", -- 9 -> 11 | 	"The preconditions of another dialog option are fulfilled/not fulfilled.", -- 9 -> 11 | ||||||
|  | 	"nothing - always true (useful for generic dialogs)", | ||||||
|  | 	"nothing - always false (useful for temporally deactivating an option)", | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- how to store these as p_type in the precondition: | -- how to store these as p_type in the precondition: | ||||||
| @ -82,7 +84,8 @@ local values_what = {"", "state", "block", "trade", | |||||||
| 	-- custom function (does not require npc_master priv) | 	-- custom function (does not require npc_master priv) | ||||||
| 	"custom", | 	"custom", | ||||||
| 	-- depends on the preconditions of another option | 	-- depends on the preconditions of another option | ||||||
| 	"other"} | 	"other", | ||||||
|  | 	"true", "false"} | ||||||
| 
 | 
 | ||||||
| -- options for "a trade" | -- options for "a trade" | ||||||
| local check_trade = { | local check_trade = { | ||||||
| @ -177,6 +180,10 @@ yl_speak_up.show_precondition = function(p, pname) | |||||||
| 		return "quest: Always false." | 		return "quest: Always false." | ||||||
| 	elseif(p.p_type == "auto") then | 	elseif(p.p_type == "auto") then | ||||||
| 		return "auto: Always true." | 		return "auto: Always true." | ||||||
|  | 	elseif(p.p_type == "true") then | ||||||
|  | 		return "true: Always true." | ||||||
|  | 	elseif(p.p_type == "false") then | ||||||
|  | 		return "false: Always false." | ||||||
| 	elseif(p.p_type == "function") then | 	elseif(p.p_type == "function") then | ||||||
| 		return "function: evaluate "..tostring(p.p_value) | 		return "function: evaluate "..tostring(p.p_value) | ||||||
| 	elseif(p.p_type == "state") then | 	elseif(p.p_type == "state") then | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user