Skip to content

Add a global lua api to serve version helper functions #734

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 5 commits into
base: dev/1.21.1
Choose a base branch
from

Conversation

SirEndii
Copy link
Member

@SirEndii SirEndii commented May 6, 2025

Added a new global accessible lua api (to every computer, turtle and pocket) to serve helper functions to retrieve versions of AP, MC and our add-ons

I primarily had this idea when I made the new bridges and 0.8 to check if a script even supports your AP version.

image

…rsions from our addons.

Also removed old unused IMC event
@SirEndii SirEndii added this to the 0.7.x milestone May 6, 2025
@SirEndii SirEndii requested a review from zyxkad May 6, 2025 21:47
@SirEndii SirEndii self-assigned this May 6, 2025
@SirEndii SirEndii added the 1.21.1 label May 6, 2025
Copy link
Contributor

github-actions bot commented May 6, 2025

Build Preview

badge

You can find files attached to the below linked Workflow Run URL (Logs).

Name Link
Commit 9eeca24
Logs https://github.com/IntelligenceModding/AdvancedPeripherals/actions/runs/14906382400
Jar Files AdvancedPeripherals PR 734
Expires At 2025-08-06T12:24:16Z

@SirEndii SirEndii requested a review from zyxkad May 6, 2025 22:38
@SirEndii SirEndii requested a review from zyxkad May 8, 2025 12:24
@@ -50,7 +50,7 @@ public class CCRegistration {

public static void register() {
IntegrationPeripheralProvider.load();
ComputerCraftAPI.registerAPIFactory(unused -> new GlobalAPHelperAPI());
ComputerCraftAPI.registerAPIFactory(unused -> new GlobalVersionsLuaAPI());
Copy link
Collaborator

@zyxkad zyxkad May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's not related to computer environment, we can also use singleton for it.

Suggested change
ComputerCraftAPI.registerAPIFactory(unused -> new GlobalVersionsLuaAPI());
ComputerCraftAPI.registerAPIFactory(unused -> GlobalVersionsLuaAPI.INSTANCE);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@@ -13,12 +13,9 @@
import java.util.Map;
import java.util.Optional;

public class GlobalAPHelperAPI implements ILuaAPI {
public class GlobalVersionsLuaAPI implements ILuaAPI {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static final String INSTANCE = new GlobalVersionsLuaAPI();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants