export to ink: support for some limited effects (setting variables to values)
This commit is contained in:
parent
13de73ecde
commit
f5ecb06ce6
@ -1,8 +1,5 @@
|
||||
-- helper functions for export_to_ink_language:
|
||||
|
||||
-- TODO: include effect setting variables to values (problem: diffrent characters allowed)
|
||||
|
||||
|
||||
-- this table will hold the functions for exporting to ink so that we don't fill that namespace too much
|
||||
yl_speak_up.export_to_ink = {}
|
||||
|
||||
@ -319,6 +316,44 @@ yl_speak_up.export_to_ink.translate_precondition_list = function(dialog, precond
|
||||
end
|
||||
|
||||
|
||||
-- small helper function
|
||||
local set_var_to_value = function(liste, var_name, op, val, vars_used)
|
||||
if(not(vars_used[var_name])) then
|
||||
vars_used[var_name] = var_name
|
||||
end
|
||||
if(op == "set_to") then
|
||||
table.insert(liste, tostring(var_name).." = "..tostring(val))
|
||||
elseif(op == "unset") then
|
||||
table.insert(liste, tostring(var_name).." = NONE ")
|
||||
elseif(op == "maximum") then
|
||||
table.insert(liste, tostring(var_name).." = max("..tostring(var_name)..", "..tostring(val))
|
||||
elseif(op == "minimum") then
|
||||
table.insert(liste, tostring(var_name).." = min("..tostring(var_name)..", "..tostring(val))
|
||||
elseif(op == "increment") then
|
||||
table.insert(liste, tostring(var_name).." = "..tostring(var_name).." + "..tostring(val))
|
||||
elseif(op == "decrement") then
|
||||
table.insert(liste, tostring(var_name).." = "..tostring(var_name).." - "..tostring(val))
|
||||
-- not supported: "set_to_current_time", "quest_step"
|
||||
end
|
||||
end
|
||||
|
||||
yl_speak_up.export_to_ink.translate_effect_list = function(dialog, effects, vars_used, n_id)
|
||||
-- collect effects that may work in ink
|
||||
local liste = {}
|
||||
-- variables may be set in effects
|
||||
for r_id, r in pairs(effects or {}) do
|
||||
if(r and r.r_type and r.r_type == "state") then
|
||||
-- state changes of variables may mostly work in ink as well
|
||||
set_var_to_value(liste, r.r_variable, r.r_operator, r.r_var_cmp_value, vars_used)
|
||||
elseif(p and p.p_type and p.p_type == "property") then
|
||||
-- same with properties
|
||||
set_var_to_value(liste, r.r_value, r.r_operator, r.r_var_cmp_value, vars_used)
|
||||
end
|
||||
end
|
||||
return liste
|
||||
end
|
||||
|
||||
|
||||
yl_speak_up.export_to_ink_language = function(dialog, n_id)
|
||||
local start_dialog = yl_speak_up.get_start_dialog_id(dialog)
|
||||
if(not(start_dialog)) then
|
||||
@ -408,7 +443,8 @@ yl_speak_up.export_to_ink_language = function(dialog, n_id)
|
||||
-- which preconditions can be translated to ink?
|
||||
local p_list = ink_export.translate_precondition_list(dialog, o_data.o_prerequisites,
|
||||
vars_used, n_id)
|
||||
local e_list = {} --TODO
|
||||
local e_list = ink_export.translate_effect_list(dialog, o_data.o_results,
|
||||
vars_used, n_id)
|
||||
|
||||
-- what remains is to print the option/choice itself
|
||||
ink_export.print_choice(tmp,
|
||||
|
Loading…
Reference in New Issue
Block a user