6de8e4e0eb
Lua verbs that raised benilla's own text, or nothing, now raise the client's usage line or message, in the client's gate order (each address read in the commits): - chat, channel and emote verbs take their argument through the usage gate, and send "" and padded names as given - `SetChatWindowName` stores an empty or padded name as given, and "" for a non-string - `GuildInviteByName` shows ERR_COMMAND_NEEDS_TARGET for nil or ""; `SetGuildInfoText` raises its usage line - `NotifyInspect`: usage, then the player, then the token - GM ticket verbs gate type, text, then the player; -1 goes out as u32::MAX - `PickupPetAction` truncates through `_ftol`, so 4294967297 is slot 1 Each fix has a test that fails without it. Fixes #2500 Fixes #2503 Fixes #2504 Fixes #2512 Fixes #2517 Fixes #2520 Fixes #2521 Fixes #2522 Fixes #2531 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.6 KiB
Rust
61 lines
2.6 KiB
Rust
//! `FollowUnit` and `FollowByName`; each hands its [`FollowRequest`] to the host, which runs the
|
|
//! start gate and arms the follow inside the call ([`super::ScriptCall::Follow`]).
|
|
//! `FollowUnit("target")` is a bare `/follow` and the `FOLLOWTARGET` binding. `FollowByName`
|
|
//! (`0x489ec0`) calls the by-name resolver `0x493aa0` for players (`0x10`) who `CanAssist` and are
|
|
//! alive, with its second argument as the exact-only flag: `UnitPopup.lua:623` passes 1, so the
|
|
//! menu never prefix-matches someone else, while `/follow rag` may. benilla parses `/follow` in
|
|
//! Rust, so these globals serve the stock UI and addons.
|
|
|
|
use mlua::Lua;
|
|
|
|
/// A follow verb, which the host applies inside its call.
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum FollowRequest {
|
|
/// `FollowUnit(unit)`: whoever the token names, of any type; the reference applies no
|
|
/// typemask here.
|
|
ByUnit(String),
|
|
/// `FollowByName(name, exactMatch)`: with `exact`, the resolver skips its longest-prefix tier
|
|
/// and takes only a whole-name, case-insensitive match.
|
|
ByName { name: String, exact: bool },
|
|
}
|
|
|
|
impl super::UiScript {
|
|
/// The follow verbs a harness's VM kept ([`Self::keep_calls`]), in call order.
|
|
pub fn take_follow_requests(&mut self) -> Vec<FollowRequest> {
|
|
self.take_calls_where(|call| match call {
|
|
super::ScriptCall::Follow(request) => Some(request.clone()),
|
|
_ => None,
|
|
})
|
|
}
|
|
}
|
|
|
|
/// Register the follow globals.
|
|
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
|
let g = lua.globals();
|
|
|
|
g.set(
|
|
"FollowUnit",
|
|
lua.create_function(|lua, unit: mlua::Value| {
|
|
// `is-number-or-string` else `Usage: FollowUnit("unit")` (`0x8426b4`, `0x489ea7`).
|
|
let unit = super::binding_abi::string_arg(lua, unit, r#"Usage: FollowUnit("unit")"#)?;
|
|
super::calls::submit(lua, super::ScriptCall::Follow(FollowRequest::ByUnit(unit)))
|
|
})?,
|
|
)?;
|
|
|
|
g.set(
|
|
"FollowByName",
|
|
lua.create_function(|lua, (name, exact): (mlua::Value, Option<mlua::Value>)| {
|
|
// `is-number-or-string` else `Usage: FollowByName("name")` (`0x8426d0`, `0x489fd5`).
|
|
let name = super::binding_abi::string_arg(lua, name, r#"Usage: FollowByName("name")"#)?;
|
|
// `GetBoolOrDefault` (`0x6f1c10`, `0x489f14`) with default false.
|
|
let exact = super::binding_abi::bool_or_default(exact.as_ref(), false);
|
|
super::calls::submit(
|
|
lua,
|
|
super::ScriptCall::Follow(FollowRequest::ByName { name, exact }),
|
|
)
|
|
})?,
|
|
)?;
|
|
|
|
Ok(())
|
|
}
|