Minor changes to help players see each other

This commit is contained in:
2024-02-28 15:35:47 -05:00
parent 0c126e62d6
commit 4495ae7133
8 changed files with 25 additions and 15 deletions

View File

@@ -152,7 +152,7 @@ public:
} }
void do_view_command(const StringVec &cmd) { void do_view_command(const StringVec &cmd) {
stdostream() << world_->tangibles_near_debug_string(actor_id_, 100); stdostream() << world_->tangibles_near_debug_string(actor_id_, 1000);
} }
void do_menu_command(const StringVec &cmd) { void do_menu_command(const StringVec &cmd) {

View File

@@ -80,6 +80,10 @@ public:
stdostream() << "Syntax Error: " << words[1] << std::endl; stdostream() << "Syntax Error: " << words[1] << std::endl;
} }
void do_view_command(const StringVec &cmd) {
stdostream() << master_->tangibles_near_debug_string(admin_id_, 1000);
}
void do_menu_command(const StringVec &cmd) { void do_menu_command(const StringVec &cmd) {
int64_t place = sv::to_int64(cmd[1], admin_id_); int64_t place = sv::to_int64(cmd[1], admin_id_);
master_->update_gui(admin_id_, place, &gui_); master_->update_gui(admin_id_, place, &gui_);
@@ -118,6 +122,7 @@ public:
else if (words[0] == "luainvoke") do_luainvoke_command(words); else if (words[0] == "luainvoke") do_luainvoke_command(words);
else if (words[0] == "luaprobe") do_luaprobe_command(words); else if (words[0] == "luaprobe") do_luaprobe_command(words);
else if (words[0] == "syntax") do_syntax_command(words); else if (words[0] == "syntax") do_syntax_command(words);
else if (words[0] == "view") do_view_command(words);
else if (words[0] == "menu") do_menu_command(words); else if (words[0] == "menu") do_menu_command(words);
else if (words[0] == "choose") do_choose_command(words); else if (words[0] == "choose") do_choose_command(words);
else if (words[0] == "tick") do_tick_command(words); else if (words[0] == "tick") do_tick_command(words);

View File

@@ -780,11 +780,9 @@ PlaneMap::~PlaneMap() {}
void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const { void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const {
into->clear(); into->clear();
int startpos = 0;
if (sc.near_ != 0) { if (sc.near_ != 0) {
if (sc.include_near_) { if (sc.include_near_) {
into->push_back(sc.near_); into->push_back(sc.near_);
startpos = 1;
} }
} }
@@ -799,7 +797,7 @@ void PlaneMap::scan(const PlaneScan &sc, util::IdVector *into) const {
} }
if (sc.sorted_) { if (sc.sorted_) {
std::sort(into->begin() + startpos, into->end()); std::sort(into->begin(), into->end());
} }
} }

View File

@@ -112,10 +112,13 @@ private:
// When true, the items are sorted by ID. // When true, the items are sorted by ID.
// WARNING: setting this to false can create // WARNING: setting this to false can create
// nondeterminism. Scans by lua should always be sorted. // nondeterminism. Scans by lua should always be sorted.
// When sorting and 'include_near' are both specified,
// the near item is returned in its sorted order.
bool sorted_; bool sorted_;
// The near ID, if nonzero, is either PREPENDED to the // The near ID is omitted from the results if include_near is false.
// results, or OMITTED from the results, depending on include_near_. // The near ID is included in the results if include_near is true.
// The near ID is ignored if near is zero.
int64_t near_; int64_t near_;
bool include_near_; bool include_near_;

View File

@@ -467,8 +467,7 @@ LuaDefine(tangible_find, "config",
"|" "|"
"|If you specify 'near', then by default, the near tangible is" "|If you specify 'near', then by default, the near tangible is"
"|filtered out of the search. If you want to include it in the" "|filtered out of the search. If you want to include it in the"
"|results, set the 'include' flag to true. In this case, the" "|results, set the 'include' flag to true."
"|near tangible will always be the first search result:"
"|" "|"
"| include : include the 'near' object in the results" "| include : include the 'near' object in the results"
"|" "|"

View File

@@ -60,17 +60,19 @@ eng::string World::tangible_ids_debug_string() const {
eng::string World::tangibles_near_debug_string(int64_t actor, int64_t distance) { eng::string World::tangibles_near_debug_string(int64_t actor, int64_t distance) {
assert(stack_is_clear()); assert(stack_is_clear());
lua_State *L = state(); lua_State *L = state();
LuaVar tangibles, database, mt; LuaVar tangibles, tanobj, classtab;
LuaExtStack LS(L, tangibles, database); LuaExtStack LS(L, tangibles, tanobj, classtab);
LS.rawget(tangibles, LuaRegistry, "tangibles"); LS.rawget(tangibles, LuaRegistry, "tangibles");
eng::ostringstream result; eng::ostringstream result;
util::IdVector tans; util::IdVector tans;
get_near(actor, distance, true, false, true, &tans); get_near(actor, distance, true, false, true, &tans);
for (int64_t id : tans) { for (int64_t id : tans) {
const Tangible *tan = tangible_get(id); const Tangible *tan = tangible_get(id);
LS.rawget(database, tangibles, id); LS.rawget(tanobj, tangibles, id);
AnimState state = tan->anim_queue_.get_final_everything(); LS.tangetclass(classtab, tanobj);
result << id << ": " << state.debug_string() << std::endl; eng::string cname = LS.classname(classtab);
AnimState state = tan->anim_queue_.get_final_persistent();
result << id << " (" << cname << "): " << state.debug_string() << std::endl;
} }
return result.str(); return result.str();
} }

View File

@@ -96,8 +96,8 @@ public:
using IdVector = util::IdVector; using IdVector = util::IdVector;
using TanVector = eng::vector<const Tangible*>; using TanVector = eng::vector<const Tangible*>;
using Redirects = eng::map<int64_t, int64_t>; using Redirects = eng::map<int64_t, int64_t>;
const float RadiusVisibility = 100.0; const float RadiusVisibility = 1000.0;
const float RadiusClose = 10.0; const float RadiusClose = 1000.0;
// Constructor. // Constructor.
// //

View File

@@ -2,6 +2,9 @@ makeclass('login')
function login.initialize(actor, place) function login.initialize(actor, place)
dprint("login.initialize:", actor) dprint("login.initialize:", actor)
local x = math.random(1, 100)
local y = math.random(1, 100)
tangible.animate(actor, nil, {action="warpto", plane="earth", xyz={x, y, 90}})
end end
function login.interface(actor, place) function login.interface(actor, place)