Skip to content

Commit 5a149f4

Browse files
committed
use setHotkeyCmd instead of dfhack.run_script
1 parent b0dba22 commit 5a149f4

2 files changed

Lines changed: 13 additions & 33 deletions

File tree

plugins/blueprint.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static bool get_options(blueprint_options &opts,
691691
!Lua::PushModulePublic(
692692
out, L, "plugins.blueprint", "parse_commandline"))
693693
{
694-
out.printerr("Failed to load blueprint Lua code");
694+
out.printerr("Failed to load blueprint Lua code\n");
695695
return false;
696696
}
697697

@@ -706,28 +706,6 @@ static bool get_options(blueprint_options &opts,
706706
return true;
707707
}
708708

709-
static bool do_gui(const vector<string> &parameters)
710-
{
711-
auto L = Lua::Core::State;
712-
color_ostream_proxy out(Core::getInstance().getConsole());
713-
Lua::StackUnwinder top(L);
714-
715-
if (!lua_checkstack(L, parameters.size() + 1) ||
716-
!Lua::PushModulePublic(out, L, "plugins.blueprint", "do_gui"))
717-
{
718-
out.printerr("Failed to load blueprint Lua code");
719-
return false;
720-
}
721-
722-
for (const string &param : parameters)
723-
Lua::Push(L, param);
724-
725-
if (!Lua::SafeCall(out, L, parameters.size(), 0))
726-
return false;
727-
728-
return true;
729-
}
730-
731709
static void print_help()
732710
{
733711
auto L = Lua::Core::State;
@@ -738,15 +716,25 @@ static void print_help()
738716
!Lua::PushModulePublic(out, L, "plugins.blueprint", "print_help") ||
739717
!Lua::SafeCall(out, L, 0, 0))
740718
{
741-
out.printerr("Failed to load blueprint Lua code");
719+
out.printerr("Failed to load blueprint Lua code\n");
742720
}
743721
}
744722

745723
command_result blueprint(color_ostream &out, vector<string> &parameters)
746724
{
747725
if (parameters.size() >= 1 && parameters[0] == "gui")
748726
{
749-
return do_gui(parameters) ? CR_OK : CR_FAILURE;
727+
std::ostringstream command;
728+
command << "gui/blueprint";
729+
for (const string &param : parameters)
730+
{
731+
command << " " << param;
732+
}
733+
string command_str = command.str();
734+
out.print("launching %s\n", command_str.c_str());
735+
736+
Core::getInstance().setHotkeyCmd(command_str);
737+
return CR_OK;
750738
}
751739

752740
blueprint_options options;

plugins/lua/blueprint.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ function parse_commandline(opts, ...)
134134
parse_positionals(opts, positionals, depth and 4 or 3)
135135
end
136136

137-
function do_gui(command, ...)
138-
local args = {...}
139-
print(('launching gui/blueprint %s'):format(table.concat(args, ' ')))
140-
dfhack.timeout(1, 'frames',
141-
function() dfhack.run_script('gui/blueprint',
142-
table.unpack(args)) end)
143-
end
144-
145137
-- compatibility with old exported API. we route the request back through
146138
-- run_command so we have a unified path for parameter processing and invariant
147139
-- checking.

0 commit comments

Comments
 (0)