mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-24 04:16:26 +02:00
Plugins: prop hunt APIs, and plugin commands in the console lookup
- reskate.entities.blueprints lists the game's object blueprints (meshes only if asked), and reskate.entities.bounds gives a blueprint's box, so a mod can pick a prop by list or at random - Attached objects take upright, turn and ground (a floor found within reach below), the "root" joint, and a 6th options argument with solid; spawned props' bodies are found and ghosted - reskate.skater.hide, reskate.world.pick, and skater.get gives right and switch - reskate.console.command takes an optional 4th table of subcommands; the console lookup suggests plugin commands word by word, and plugin commands lists the subcommands - objbody: a test command for finding which body setter takes a prop out of collision
This commit is contained in:
1 parent
c35e9a357b
commit
45346b122c
26 files changed
+1238
-36
No files matched your search
@@ -454,9 +454,10 @@ std::string list_commands() {
|
||||
std::string text;
|
||||
const auto add = [&](const std::vector<Status>& all, std::string_view suffix) {
|
||||
for (const auto& plugin : all)
|
||||
for (const auto& [name, help] : plugin.commands) {
|
||||
for (const auto& command : plugin.commands) {
|
||||
if (!text.empty()) text += '\n';
|
||||
text += std::format("{} - {} ({}{})", name, help, plugin.id, suffix);
|
||||
text += std::format("{}{}{} - {} ({}{})", command.name, command.args.empty() ? "" : " ", command.args, command.help, plugin.id,
|
||||
suffix);
|
||||
}
|
||||
};
|
||||
add(host->status(), "");
|
||||
@@ -464,6 +465,26 @@ std::string list_commands() {
|
||||
return text.empty() ? "No plugin has a console command." : text;
|
||||
}
|
||||
|
||||
std::vector<CommandHint> command_hints() {
|
||||
static std::vector<CommandHint> hints;
|
||||
static std::uint64_t next{};
|
||||
const auto now = GetTickCount64();
|
||||
if (now < next) return hints;
|
||||
next = now + 500;
|
||||
hints.clear();
|
||||
if (!host) return hints;
|
||||
const auto add = [&](const std::vector<Status>& all, std::string_view suffix) {
|
||||
for (const auto& plugin : all)
|
||||
for (const auto& command : plugin.commands)
|
||||
if (std::none_of(hints.begin(), hints.end(), [&](const auto& hint) { return hint.name == command.name; }))
|
||||
hints.push_back({command.name, command.args, command.help, plugin.id + std::string(suffix)});
|
||||
};
|
||||
add(host->status(), "");
|
||||
if (serving) add(server_host->status(), "@server");
|
||||
std::sort(hints.begin(), hints.end(), [](const auto& a, const auto& b) { return a.name < b.name; });
|
||||
return hints;
|
||||
}
|
||||
|
||||
// "<id>@server" names a server copy (on this game while it hosts a lobby); a plain id, the player's copy.
|
||||
namespace {
|
||||
template <class Do> std::string either(std::string_view id, Do&& act) {
|
||||
|
||||
Reference in new issue
Block a user