In a Partition puzzle, a recipe with this single line:
print(filter.GetBonus("Exploration"))
will crash the client everytime with:
log.txt:
UNHANDLED EXCEPTION
1: interactive::util::FilterResultCacheable::get_result_bonus_value +57 bytes (no line)
2: standalone::application::luaV2_filter_GetBonus +368 bytes (no line)
3: luaD_precall +425 bytes (no line)
4: luaV_execute +3242 bytes (no line)
5: luaD_call +99 bytes (no line)
6: lua_call +83 bytes (no line)
7: luaD_rawrunprotected +76 bytes (no line)
8: luaD_pcall +53 bytes (no line)
9: lua_pcall +93 bytes (no line)
10: interactive::application::shared::lua::LuaScripter::exec_string +93 bytes (no line)
11: interactive::application::shared::lua::LuaExec::on_exec +88 bytes (no line)
12: boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void,boost::_mfi::mf1<void,interactive::application::shared::lua::LuaExec,std::basic_string<char,std::char_traits,std::allocator > const &>,boost::_bi::list2<boost::_bi::value<interactive::application::shared::lua::LuaExec *>,boost::_bi::value<std::basic_string<char,std::char_traits,std::allocator > > > >,void>::invoke +22 bytes (no line)
13: boost::function0::operator() +120 bytes (no line)
14: interactive::util::Thread::thread_entry_func +69 bytes (no line)
15: interactive::util::Thread::win32_thread_startup_helper +11 bytes (no line)
16: BaseThreadInitThunk +36 bytes (no line)
17: RtlValidSecurityDescriptor +282 bytes (no line)
18: RtlValidSecurityDescriptor +234 bytes (no line)
You are trying to get the value of a bonus that does not exist. Exploration is not a score bonus in these puzzles; it is a condition (yes/no). Try this:
print(filter.ConditionSatisfied("Exploration"))
Admittedly, the game should just put a lua error in the script output rather than crashing!
Exactly or return the value of 'Explored' (which would be useful in itself).
Please notice that if you interrogate filter.GetNames(), it will return "Exploration" as a valid FilterName.
And this works (except the last line obviously):
FilterNames = filter.GetNames()
if #FilterNames > 0 then
print("There are filter in this puzzle:")
for i=1,#FilterNames do
msg = " '"..FilterNames[i].."' is "
state = "DISABLED"
if filter.IsEnabled(FilterNames[i]) then state = "ENABLED" end
msg = msg..state.." and the condition is "
condition = "NOT MET"
if filter.ConditionSatisfied(FilterNames[i]) then condition = "MET" end
msg = msg..condition
print(msg)
–print(" with a score of "..filter.GetBonus(FilterNames[i])) –this crashes the client 09/23/2018
end
end
Is there a LUA command to get the RMSD value for a structure in the Partition Function Puzzles?
and the old "AreConditionsMet()" doesn't work anymore for this.
Could we get this bug/crash function working?
Even if it is not technically a "bonus", it could help in identifying if our solutions are far enough from original and direct recipes…
Thanks
Okay, I think I have a patch for this.
The current behavior of the fix is to raise a Lua error (the same sort of error as if you misspell a filter name, with different wording) if you attempt to call GetBonus() on a filter which is a pass/fail only filter. Additionally, the patch would add a function (filter.HasBonus()) which returns true only if GetBonus will succeed.
Does that seem like a reasonable fix? Or are the use cases surrounding GetBonus() that I'm not anticipating?
Can you make a LUA command to get the RMSD value for a structure,
like the RMSD values reported in the Score Window in the recent
Partition Function Puzzles? Then we can use this LUA command in
Recipes to record, report, & optimize based on the RMSD value.