Skip to content
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

Add more mekanism input adapters #19

Merged

Conversation

bananasov
Copy link
Contributor

@bananasov bananasov commented Oct 7, 2023

THIS IS A DRAFT, THERE IS NO WAY IN HELL I'D BE ABLE TO ADD SUPPORT FOR EVERYTHING
This PR adds support for even more mekanism inputs!!!! I'd hope to add support for EVERYTHING but currently it is very basic. There are over 700 rows in the CSV im looking up stuff in, its a really bad CSV too, send help.

List of blocks that have support

  • Antiprotonic Nucleosynthesizer
  • Bin
  • Bio Generator
  • Boiler Multiblock (formed)
  • Boiler Valve
  • Chemical Crystallizer
  • Chemical Dissolution Chamber
  • Chemical Infuser
  • Chemical Oxidizer
  • Chemical Tank
  • Chemical Washer
  • Combiner
  • Combining Factory
  • Compressing/Injecting/Purifying Factory
  • Compressing/Injecting/Purifying Machine
  • Digital Miner
  • Dimensional Stabilizer
  • Diversion Transporter
  • Dynamic Tank Multiblock (formed)
  • Electric Machine
  • Electric Pump
  • Electrolytic Separator
  • Energy Cube
  • Factory Machine
  • Fluid Tank
  • Fluidic Plenisher
  • Formulaic Assemblicator
  • Fuelwood Heater
  • Gas Generator
  • Heat Generator
  • Isotopic Centrifuge
  • Laser
  • Laser Amplifier
  • Laser Tractor Beam
  • Logistical Sorter
  • Mechanical Pipe
  • Metallurgic Infuser
  • Metallurgic Infuser Factory
  • Nutritional Liquifier
  • Oredictionificator
  • Painting Machine
  • Pigment Extractor
  • Pigment Mixer
  • Precision Sawmill
  • Pressurized Reaction Chamber
  • Pressurized Tube
  • QIO Dashboard
  • QIO Drive Array
  • QIO Exporter
  • QIO Importer
  • QIO Machine
  • Quantum Entangloporter
  • Radioactive Waste Barrel
  • Resistive Heater
  • Rotary Condensentrator
  • SPS Multiblock (formed)
  • SPS Port
  • Sawing Factory
  • Seismic Vibrator
  • Solar Generator
  • Solar Neutron Activator
  • Teleporter
  • Thermal Evaporation Multiblock (formed)
  • Universal Cable
  • Wind Generator

look i have no idea if this works, but from eyeballing `methods.csv` and
reading lines in ComputerCraft itself
I am fairly certain that this might work
although i could be wrong because mekanism
sucks sometimes.
not something special really, just the bare minimum to monitor a chemical tank
how the fuck did i miss that..
@cyberbit
Copy link
Owner

cyberbit commented Oct 7, 2023

This is great! Whenever you get to a stopping point I will review in more detail but looks pretty good so far!

The only note I would make is concerning units. For consistency with other adapters I would use B and B/t for gas/chemicals/fluids (see below for example from FissionReactorInputAdapter):

image

Thanks for contributing ❤️

@cyberbit cyberbit added enhancement New feature or request mod: Mekanism Related to Mekanism and affiliates sw: Adapter Inputs and outputs labels Oct 7, 2023
@cyberbit
Copy link
Owner

cyberbit commented Oct 7, 2023

FYI, I found this improved computer API documentation: https://mekanism.github.io/computer_data/10.4.0.html

This is for the very newly released 1.20.x Mekanism version, so it may be slightly off but is probably better than the spreadsheet.

@bananasov
Copy link
Contributor Author

FYI, I found this improved computer API documentation: https://mekanism.github.io/computer_data/10.4.0.html

This is for the very newly released 1.20.x Mekanism version, so it may be slightly off but is probably better than the spreadsheet.

holy shit that is so much better

@cyberbit
Copy link
Owner

Hey @Autist69420, are you at a stopping point with this? If so I can merge and continue with the rest of them. :)

@bananasov
Copy link
Contributor Author

bananasov commented Oct 22, 2023

Hey @Autist69420, are you at a stopping point with this? If so I can merge and continue with the rest of them. :)

Been a bit lazy lately, you can merge everything I have now if ya want I can always open more PRs :p

although I haven't added everything to the input.lua file yet so 🤷

@cyberbit cyberbit self-assigned this Oct 23, 2023
@cyberbit
Copy link
Owner

It happens to the best of us. :)

I will merge everything to feature/more-mekanism and open another draft PR so progress can still be tracked. I want to take a deeper look at the code and try to define better categories so the standard is the same across Mekanism adapters.

@cyberbit cyberbit changed the base branch from main to feature/more-mekanism October 23, 2023 15:48
@cyberbit cyberbit marked this pull request as ready for review October 23, 2023 15:54
Copy link
Owner

Choose a reason for hiding this comment

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

I may move Mekanism stuff to input/mekanism.lua to keep this file a little more tidy, haven't decided yet. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like the smartest approach since this is a little messy 😛

Copy link
Owner

@cyberbit cyberbit left a comment

Choose a reason for hiding this comment

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

Sorry ahead of time for the pings!!

Adapters reviewed:

  • BioGeneratorInputAdapter
  • ChemicalTankInputAdapter
  • DigitalMinerInputAdapter
  • DynamicTankInputAdapter
  • GasGeneratorInputAdapter
  • IsotopicCentrifugeInputAdapter
  • LaserAmplifierInputAdapter
  • LaserInputAdapter
  • MechanicalPipeInputAdapter
  • PressurizedTubeInputAdapter
  • QuantumEntangloporterInputAdapter
  • UniversalCableInputAdapter

Current input categories for Mekanism (I will expand this as I review)

  • basic: This should included the fundamental indicators for a machine. For example, most "filled percentage" values and energy production/consumption rates are appropriate here. Avoid including specific max/min/current capacity metrics; those usually belong in their respective category.
  • advanced: Machine-specific configuration, flags, or statuses
  • fuel: Any non-basic metric relating to a resource consumed for energy production, like fissile fuel, biofuel, ethylene, etc.
  • coolant: Any non-basic metric relating to coolant
  • waste: Any non-basic metric relating to waste
  • formation: Any non-basic metrics related to facts about the machine itself, such as physical dimensions, component parts, and mod-level configurations.
  • energy: Any non-basic metrics related to energy. Most often this will be energy capacity.
  • steam: This category is only used by the turbine and will probably go away because it is dumb.
  • input: Any non-basic metric relating to input resources, except energy (items, fluids, chemicals, etc.)
  • output: Any non-basic metric relating to output resources, except energy (items, fluids, chemicals, etc.)

metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = (generator.getBioFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue!
metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source })
metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = (generator.getBioFuelNeeded() / 1000), unit = 'B/t', source = source })
metrics:insert(Metric{ name = self.prefix .. 'production_rate', value = mekanismEnergyHelper.joulesToFE(generator.getProductionRate()), unit = nil, source = source })
Copy link
Owner

Choose a reason for hiding this comment

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

Unit should be 'FE/t'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6814f0d, hopefully

metrics:insert(Metric{ name = self.prefix .. 'fuel_capacity', value = (generator.getBioFuelCapacity() / 1000), unit = "B", source = source })
metrics:insert(Metric{ name = self.prefix .. 'fuel_amount', value = (generator.getBioFuel().amount / 1000), unit = "B", source = source }) -- might error might not, no clue!
metrics:insert(Metric{ name = self.prefix .. 'fuel_filled_percentage', value = generator.getBioFuelFilledPercentage(), unit = nil, source = source })
metrics:insert(Metric{ name = self.prefix .. 'fuel_needed', value = (generator.getBioFuelNeeded() / 1000), unit = 'B/t', source = source })
Copy link
Owner

Choose a reason for hiding this comment

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

I think the unit here should be B? From what I can tell, needed is max_capacity - current

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 6814f0d

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

I think to preserve API parity, fuel_* should be changed to bio_fuel_*.

Categories should be expanded:

Basic:

  • energy_filled_percentage
  • bio_fuel_filled_percentage
  • production_rate

Fuel:

  • bio_fuel_capacity
  • bio_fuel
  • bio_fuel_needed

Energy:

  • energy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

blehhh my responses are gonna get sillier the more send it: 6814f0d

self.prefix = 'mekdigitalminer:'

-- TODO make these constants
local allCategories = {
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend basic and energy; may add advanced and formation in later updates.

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

Categories should be expanded:

Basic:

  • energy_filled_percentage
  • energy_usage
  • get_to_mine
  • is_running

Energy:

  • energy

metrics:insert(Metric{ name = self.prefix .. 'energy', value = mekanismEnergyHelper.joulesToFE(miner.getEnergy()), unit = "FE", source = source })
metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (miner.getEnergyFilledPercentage()), unit = nil, source = source })
metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = mekanismEnergyHelper.joulesToFE(miner.getEnergyUsage()), unit = "FE/t", source = source })
metrics:insert(Metric{ name = self.prefix .. 'get_to_mine', value = miner.getToMine(), unit = "items", source = source })
Copy link
Owner

@cyberbit cyberbit Oct 24, 2023

Choose a reason for hiding this comment

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

Metric name should not include the function verb, recommend to_mine.

Use singular units whenever possible, recommend "item" here.

metrics:insert(Metric{ name = self.prefix .. 'energy_filled_percentage', value = (miner.getEnergyFilledPercentage()), unit = nil, source = source })
metrics:insert(Metric{ name = self.prefix .. 'energy_usage', value = mekanismEnergyHelper.joulesToFE(miner.getEnergyUsage()), unit = "FE/t", source = source })
metrics:insert(Metric{ name = self.prefix .. 'get_to_mine', value = miner.getToMine(), unit = "items", source = source })
metrics:insert(Metric{ name = self.prefix .. 'is_running', value = (miner.isRunning() and 1 or 0), unit = nil, source = source })
Copy link
Owner

Choose a reason for hiding this comment

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

Remove function verb from name, recommend running.

Thought about this one for a bit, as I do like labelling true/false flags differently. But, Induction Matrix adapter does this for isFormed() => formed, so probably better to follow the precedent.

@bananasov
Copy link
Contributor Author

Christ that is a lot of reviews, I'll get to nibbling on them slowly over the week

self:super('constructor')

-- TODO this will be a configurable feature later
self.prefix = 'mekchemtank:'
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend mekdynamictank: for prefix

self.prefix = 'mekchemtank:'

-- TODO make these constants
local allCategories = {
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend basic category only, see comments in read()

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend putting everything in basic category to match Chemical Tank adapter layout.

I think tank_capacity and chemical_tank_capacity would be the most correct here. Dynamic Tanks can store more mB of chemical vs fluid for the same structure dimensions, so there are technically two maximum capacities depending on the contents. 🤷

self.prefix = 'mekgasgen:'

-- TODO make these constants
local allCategories = {
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend basic, fuel, energy

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

Categories should be expanded:

Basic:

  • energy_filled_percentage
  • fuel_filled_percentage
  • production_rate

Fuel:

  • fuel_amount
  • fuel_capacity
  • fuel_needed

Energy:

  • energy

self:super('constructor')

-- TODO this will be a configurable feature later
self.prefix = 'mekunicable:'
Copy link
Owner

Choose a reason for hiding this comment

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

Prefix should be mekcentrifuge:

self.prefix = 'mekunicable:'

-- TODO make these constants
local allCategories = {
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend adding energy category

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend this category layout:

Basic:

  • energy_usage
  • energy_filled_percentage
  • input_filled_percentage
  • output_filled_percentage

Energy:

  • energy
  • energy_needed

Input:

  • input
  • input_capacity

Output:

  • output
  • output_capacity

self.prefix = 'meklaseramp:'

-- TODO make these constants
local allCategories = {
Copy link
Owner

Choose a reason for hiding this comment

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

Recommend basic, energy

-- do nothing

-- Literally all we have lmao
elseif v == 'basic' then
Copy link
Owner

Choose a reason for hiding this comment

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

Rename energy_max to max_energy to align with induction matrix and turbine adapters. I would also add an energy category:

Basic:

  • energy_filled_percentage

Energy:

  • energy
  • max_energy
  • energy_needed

The energy category across most machines is nearly identical... I may try to look into ways of applying metric "templates" for common categories in the future to improve code reuse.

Copy link
Owner

@cyberbit cyberbit Oct 25, 2023

Choose a reason for hiding this comment

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

Same notes on this as Laser Amplifier:

  • category list update
  • energy_max => max_energy
  • move everything to energy category except energy_filled_percentage

@cyberbit
Copy link
Owner

Merging this for now, as the Mekanism integration is being rewritten with fluent queries.

@cyberbit cyberbit merged commit a8b2dc8 into cyberbit:feature/more-mekanism Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mod: Mekanism Related to Mekanism and affiliates sw: Adapter Inputs and outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants