Skip to content

NativeElement.invoke and openMenu('crafting'): a script switches off the recipe list's empty tabs - #350

Closed
Kharote wants to merge 1 commit into
mainfrom
feat/crafting-tabs
Closed

Kharote wants to merge 1 commit into
mainfrom
feat/crafting-tabs

Conversation

@Kharote

@Kharote Kharote commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

What this changes

A server with its own smithing recipes (an armourer's 21, all in the Other category) wanted the recipe book's empty tabs gone: the list keeps its tabs (short swords, long swords, axes, other) lit whatever recipes it holds. The tabs are switched in the list's movie (ApseCraftingList, SetEnableTabButton(tab, enabled)), which the element does not declare, so NativeElement.call could not reach it.

  • New client NativeElement.invoke(clip, method, args): calls an ActionScript method of a clip of a game screen, or a function of its movie with clip '', also one the element does not declare. Every instance of the element that has the clip gets the call (as load does: the game draws its screens on other instances); the first answer that is not null comes back.
  • NativeUI.openMenu('crafting'): the crafting page has no key of its own, so it now opens as the inventory, then the menu moves to it as its tab key (move_crafting) does: the screen's tab switch, its vtable slot 7, with the page and 0.
  • Docs: NativeElement.invoke (since 1.2.2) with an example that switches off empty smithing tabs on nativeScreenOpened, and the tab numbers (0 short swords, 1 long swords, 2 axes, 3 other, 4 potions, 5 poisons, 6 herbs); NativeUI.openMenu names 'crafting'. C# SDK regenerated.

How it was tested

  • node --test Backend/scripting/runtimes/js/client_native_ui.test.cjs: 15 passed (new: invoke's request, its path, its argument checks).
  • SDK examples type-check (typecheck_examples.cjs): the new ones pass in JS, TS, Lua and C# (the one error left is in the docs repository's carts.md, untouched here).
  • Kit, one game (WHGame 1.5.5): openMenu('crafting') opened the menu's crafting page ("menu page 1 opened by a script: yes"; before, the open was refused). invoke('', 'SetEnableTabButton', [tab, false]) switched off tabs 0, 1, 2 and 4 (their labels went, the others stayed). The docs example as a client script (on nativeScreenOpened for ApseCraftingList, 200 ms later) switched off tabs 0 to 2 each time the page opened, screenshots before and after.

Checklist

  • I read CONTRIBUTING.md and agree that my contribution is licensed as it says.
  • The change is my own work: no code, assets or dumps that are not mine or that come from the game.
  • python Dev/tools/format_source.py --check passes.
  • Tests cover the change, and the checks of this pull request pass.
  • Public behaviour that changed is documented (KCD-Synced/KCDS-DOCS) or needs no docs.

…the recipe list's empty tabs

The anvil's recipe list keeps its tabs (short swords, long swords, axes,
other) whatever recipes a server gives it, and NativeElement.call reaches
only the functions an element declares, not the list's own
SetEnableTabButton.

- New client NativeElement.invoke(clip, method, args): calls an
  ActionScript method of a clip of a game screen, or a function of its
  movie with clip '', on every instance that has the clip, and returns the
  first answer.
- NativeUI.openMenu('crafting'): a page no key opens comes up as the
  inventory, then the menu moves to it as its tab key does.
@Kharote

Kharote commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Shipped in 1.2.2 (#351, release v1.2.2).

@Kharote Kharote closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant