Skip to content

Allow GPS to use modems connected through a hub #2135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: mc-1.20.x
Choose a base branch
from

Conversation

MCJack123
Copy link
Contributor

This PR changes the gps.locate code to use peripheral.find to look for a modem, instead of manually enumerating through rs.getSides(), which is both more verbose than necessary and skips over networked modems.

@fatboychummy
Copy link
Contributor

fatboychummy commented Mar 10, 2025

Hmm, I wonder how useful this would be to also add this to gps host, then also allow passing in a peripheral name as 5th argument to override the peripheral.find and force it to use that one?

With this, we could create a complete GPS array with a single computer + multishell.

-- startup.lua
shell.run("bg gps host x1 y1 z1 modem_1")
shell.run("bg gps host x2 y2 z2 modem_2")
-- ...

@Wojbie
Copy link
Contributor

Wojbie commented Mar 10, 2025

I believe gps is skipping networked modems on purpose, because networked modems return distance to full block modem they are networked from, not computer, so you would get position of that full block modem instead of computer itself. This feels like breaking change.

EDIT: #1585 adding modem argument would be indeed a way to implement this addition without risking breaking change, because that way only programs that explicitly opt in the new logic to get position of networked modem would get its position, and there is no risk of program confusing its position with modem one because default logic changed.

@SquidDev
Copy link
Member

Thanks for the PR! I definitely agree this makes sense to have, but not sure it should be by default. If a computer has both a local and networked modem attached (I'm not here to judge!), you probably want to prioritise the former.

I wonder if a better approach here would be to do #1585 and just add a modem argument?


RE gps host, I think it would be nice to have a gps.host function, which possibly supports multiple modems, but probably out-of-scope for this PR.

networked modems

This is wireless modems connected via a wired one, rather than wired ones themselves.

@SquidDev SquidDev added enhancement An extension of a feature or a new feature. area-CraftOS This affects CraftOS, or any other Lua portions of the mod. labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. enhancement An extension of a feature or a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants