Skip to content

Conversation

@JensDoesLua
Copy link

@JensDoesLua JensDoesLua commented Dec 20, 2025

We have ObjectRef:get_wield_index(), which returns the number of the item currently selected in the hotbar.
There is no ObjectRef:set_wield_index(index) yet, which is is added by this PR.

This method can be called by a server side mod, so a new network package is added to tell the client that it should change to the specified index.

To do

This PR is Ready for Review.

How to test

player:set_wield_index(3)

Usecase

I am working on a mod which provides a radial menu. One usecase would be to support number keys and/or mouse wheel up/down for changing the current selection. This is already possible by hiding the wielded item and hotbar and temporarily replacing the inventory. The only problem is that the selected item should be restored when the menu is closed.
This PR provides the changes which are required to make this possible. There are no also no latency problems because this is rarely operation (and the selected index can be restored before showing the hotbar again, so the user will not notice it)

@cx384 cx384 added @ Script API Feature ✨ PRs that add or enhance a feature Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand labels Dec 20, 2025
@cx384
Copy link
Member

cx384 commented Dec 20, 2025

I'm not sure if we want the server to be able to do this, because of responsiveness.
It would probably be better to do it with SSCSM in the foreseeable future.
Also, better create an issue first and explain why we need this feature, e.g. by listing some usecases.

@JensDoesLua
Copy link
Author

@cx384 thank you for your feedback! I added the usecase to the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature ✨ PRs that add or enhance a feature Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand @ Script API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants