Small fix
This commit is contained in:
parent
31e1b9b7fb
commit
06187a79ac
@ -182,11 +182,6 @@ namespace ui_scripting
|
|||||||
auto game_type = game();
|
auto game_type = game();
|
||||||
lua["game"] = game_type;
|
lua["game"] = game_type;
|
||||||
|
|
||||||
game_type["addlocalizedstring"] = [](const game&, const std::string& a, const std::string& b)
|
|
||||||
{
|
|
||||||
localized_strings::override(a, b);
|
|
||||||
};
|
|
||||||
|
|
||||||
game_type["sharedset"] = [](const game&, const std::string& key, const std::string& value)
|
game_type["sharedset"] = [](const game&, const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
scripting::shared_table.access([key, value](scripting::shared_table_t& table)
|
scripting::shared_table.access([key, value](scripting::shared_table_t& table)
|
||||||
@ -248,7 +243,7 @@ namespace ui_scripting
|
|||||||
const auto alternate = name.starts_with("alt_");
|
const auto alternate = name.starts_with("alt_");
|
||||||
const auto weapon = ::game::G_GetWeaponForName(name.data());
|
const auto weapon = ::game::G_GetWeaponForName(name.data());
|
||||||
|
|
||||||
char buffer[0x400] = { 0 };
|
char buffer[0x400] = {0};
|
||||||
::game::CG_GetWeaponDisplayName(weapon, alternate, buffer, 0x400);
|
::game::CG_GetWeaponDisplayName(weapon, alternate, buffer, 0x400);
|
||||||
|
|
||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
@ -281,7 +276,9 @@ namespace ui_scripting
|
|||||||
std::vector<std::string> args{};
|
std::vector<std::string> args{};
|
||||||
for (const auto& value : va)
|
for (const auto& value : va)
|
||||||
{
|
{
|
||||||
args.push_back(to_string(value)[0].as<std::string>());
|
const auto value_str = to_string(value);
|
||||||
|
|
||||||
|
args.push_back(value_str[0].as<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
::scheduler::once([name, args]()
|
::scheduler::once([name, args]()
|
||||||
|
@ -78,6 +78,26 @@ namespace ui_scripting
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arguments get_return_values(game::hks::HksObject* base)
|
||||||
|
{
|
||||||
|
const auto state = *game::hks::lua_state;
|
||||||
|
const auto count = static_cast<int>(state->m_apistack.top - base);
|
||||||
|
arguments values;
|
||||||
|
|
||||||
|
for (auto i = count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
const auto v = get_return_value(i);
|
||||||
|
values.push_back(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.size() == 0)
|
||||||
|
{
|
||||||
|
values.push_back({});
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
bool notify(const std::string& name, const event_arguments& arguments)
|
bool notify(const std::string& name, const event_arguments& arguments)
|
||||||
{
|
{
|
||||||
const auto state = *game::hks::lua_state;
|
const auto state = *game::hks::lua_state;
|
||||||
@ -127,10 +147,8 @@ namespace ui_scripting
|
|||||||
push_value(*i);
|
push_value(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto num_args = static_cast<int>(arguments.size());
|
game::hks::vm_call_internal(state, static_cast<int>(arguments.size()), -1, 0);
|
||||||
|
const auto args = get_return_values(top);
|
||||||
game::hks::vm_call_internal(state, num_args, -1, 0);
|
|
||||||
const auto args = get_return_values();
|
|
||||||
state->m_apistack.top = top;
|
state->m_apistack.top = top;
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace ui_scripting
|
|||||||
|
|
||||||
script_value get_return_value(int offset);
|
script_value get_return_value(int offset);
|
||||||
arguments get_return_values();
|
arguments get_return_values();
|
||||||
|
arguments get_return_values(game::hks::HksObject* base);
|
||||||
|
|
||||||
bool notify(const std::string& name, const event_arguments& arguments);
|
bool notify(const std::string& name, const event_arguments& arguments);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user