Giter Club home page Giter Club logo

du-container-monitor's Introduction

DU-Container-Monitor

OVERVIEW
This code is destined to Dual Universe game.
This is a Container monitor for pure and ore materials. It can be used to monitor container percentages and it readouts. It was design to have a Container Hub element side each item.

This HUD was designed for a Large Transparent Screen(or two). Each screen can gather 20 materials. It uses a Zone detector to turn up every board for optimal CPU usage.


HOW TO SETUP HUD:
Slot1: CORE
Slot2: SCREEN_A
Slot3-6: SCREEN_B (optional) / DOOR1 (optional) / DOOR2 (optional) / Databank (optional - no need to rename it)


INSTRUCTIONS:
1. Place Main board
2. Place a Transparent Screen L or similar
3. Link CORE (no need to rename slot to CORE because it will autodetect)
4. Link SCREENS
5. Copy minified code from Main Board file, and paste it under advanced options on board options.
NOTE: when you copy paste the code, it will rename automatically slot1 to CORE and slot2 to SCREEN_A (if you are using a second screen, just neeed to rename the other slot to SCREEN_B)

6. Edit Lua script and check if you have your screen name right. SCREEN_A for first, and if you want a 2nd one name it SCREEN_B
7. Check parameters (setup refresh rate in seconds, containers default litre space, min and max percentage for red and green indicators)
8. Check Labeling Instruction below to know how to rename containers/hubs

OPTIONAL
9. Link Databank (no need to rename slot to DB because it will autodetect)

If you want to start the board with your presence
10. Link Relay to board and detector zone or manual button for example (optional) (you can always turn the board manually)


Labeling Instructions:
CH stands for ContainerHub
C stands for Container
1 for quantity of containers
L for size of the container
ACANTHITE for material type

Change everything accordingly except CH or C.
Ex.: CH_3S_CARBON (you have 3 small containers with carbon), CH_6L_IRON (you have 6 large containers with iron), C_1M_IRON (you have 1 M containers with IRON (the number one could be omitted, like C_M_IRON)

Material name always in CAPS. List: HEMATITE, IRON, BAUXITE, ALUMINIUM, COAL ,CARBON ,QUARTZ ,SILICON ,LIMESTONE ,CALCIUM ,ACANTHITE ,SILVER ,MALACHITE ,COPPER ,NATRON, SODIUM, PYRITE, SULFUR, PETALITE, LITHIUM, CHROMITE, CHROMIUM, GARNIERITE, NICKEL, GOLDNUGGETS, GOLD, RHODONITE, MANGANESE, CRYOLITE, FLUORINE, COBALTITE, COBALT, KOLBECKITE, SCANDIUM, COLUMBITE, NIOBIUM, VANADINITE, VANADIUM, ILMENITE, TITANIUM, OXYGEN, HYDROGEN, WARPCELL


CUSTOM ORDER ON SCREEN:

At system start() you will find two variables (SCREENA and SCREENB).

local SCREENA = {"HEMATITE","IRON","BAUXITE","ALUMINIUM","COAL","CARBON","QUARTZ","SILICON","LIMESTONE","CALCIUM",
"MALACHITE","COPPER","NATRON","SODIUM","CHROMITE","CHROMIUM","ACANTHITE","SILVER","PYRITE","SULFUR"}

local SCREENB = {"PETALITE","LITHIUM","GARNIERITE","NICKEL","GOLDNUGGETS","GOLD","CRYOLITE","FLUORINE",
"COBALTITE","COBALT","KOLBECKITE","SCANDIUM","RHODONITE","MANGANESE","COLUMBITE","NIOBIUM","VANADINITE", "VANADIUM","ILMENITE","TITANIUM"}


This will define the order that materials are placed on screen. If you need an empty space use EMPTY. You can also use OXYGEN, HYDROGEN or WARPCELL
Please use it wisely.

-- LIST OF ORE/PURES:
-- "HEMATITE","IRON","BAUXITE","ALUMINIUM","COAL","CARBON","QUARTZ","SILICON"
-- "LIMESTONE","CALCIUM","MALACHITE","COPPER","NATRON","SODIUM","CHROMITE","CHROMIUM","ACANTHITE"
-- "SILVER","PYRITE","SULFUR","PETALITE","LITHIUM","GARNIERITE","NICKEL","GOLDNUGGETS","GOLD"
-- "CRYOLITE","FLUORINE","COBALTITE","COBALT","KOLBECKITE","SCANDIUM","RHODONITE","MANGANESE"
-- "COLUMBITE","NIOBIUM","VANADINITE","VANADIUM","ILMENITE","TITANIUM"

-- EXTRA MATERIALS TO USE: "OXYGEN", "HYDROGEN", "WARPCELL"

-- On this next arrays you will place witch order you like
-- Read always left to right, then next line.
-- YOU CAN SET "EMPTY" if you need a blank space




DOORS:

If you are using doors, just need to link them to the board. Name the slots DOOR1 and DOOR2 (optional).
Activate at parameters (UseDoors), and at the final function at System/start, edit the caracter names that will trigger the doors.

EXTRA:

If you want you could format first screen with 4 columns. You could use this setting if you are not planning to use any container hub over the screen. Just uncheck "UseContainerHub" at parameters, and reload board.


Bonus Screen

This is a HTML only board. Feel free to change the names to your liking.


CHANGE LOG
v1.4 11 Nov 2020 - first time i remembered to create a log
v1.7 17 Nov 2020
Major refactoring
Added DB for upgrade purposes (storing user configs)
Added (L / kL / kt) readout below progress bar
Added capability to read containers and container hubs ( C_1L_IRON or CH_1L_IRON)
Restored old terminology to setup screen variables. Ore/Pure names instead m1,m2,m3,etc...
Info readouts when screen is setup and no container/hub found
Correct order for T1,T2,T3,T4 when using 2 full screens/1 without "hubsonscreen"
Added showHudWidget variable. Please turn it to true for DEBUG purposes.
Added capability to have 10 containers in the name. (Ex.: CH_10L_HEMATITE)

Thanks to: Jericho,Archaegeo,Kumare,Tricky Trixy,-CML- Schoff for all input.
v1.8 17 Nov 2020
Container "C_" now working as intended. You can use either C_L_IRON or C_1L_IRON (no meaning to say that the "one" container is 1.)
If you name 2 containers with the same ore/pure it will sum values of the two (or more)

v1.9 01 Dec 2020
Refactoring
Added capacity to handle items that have litres diferent than ore/pures.
Fixed percentages with .333333 or .666666 infinite readout.
Now the screen shows item name instead of the variable name. Now we can all have "Gold Nuggets"
Improved ReadME info to help new players


Credits carmopereira

Buy Me a Coffee at ko-fi.com

A big thanks to Jericho :) Your help is gold

NOTE: Any issue, please contact carmo#1590 at Discord or at DU_CONTAINER_HUD channel on DU Open Source Initiative Discord Server https://discord.gg/tBteJZSQxe

du-container-monitor's People

Contributors

carmopereira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

du-container-monitor's Issues

Feature request: Add parsing of target amount from container name

I'd like to be able to specify a target amount in the container hub name.

To be used in 2 ways:

  1. Color based on percentage of target amount
  2. Difference between current amount and target amount displayed, along with current amount and capacity
    For example, 200 units in container that holds 1000 with target of 500 might display 200/300/1000
    Another example, 600 units in container that holds 1000 with target of 500 might display 600/-100/1000

hub mass

take into account the mass of the hub: 55.8
For high precision :)

Display units on current amount

Need to show units on the current amount for clarity.

For example, right now if I see 54.0/192.0kL, it is impossible to tell from the numbers alone whether it means 54L or 54kL.

improvements

Please check all cycles and local variables across the code.
Please see comments below

if core ~= nil then
	 local elementsIdList = core.getElementIdList()
	 for _,id in pairs(elementsIdList) do -- use ipairs instead
		local elementType = core.getElementTypeById(id):lower()
		if elementType:find("container") then
			name = core.getElementNameById(id) -- should be local
			if string.match(name, "CH_") or string.match(name, "C_") then
			temp = split(name, "_") -- should be local			 
 				table.insert(containersIdList , {id, temp[1], string.match(temp[2], "%d+"), string.sub(temp[2], -1), temp[3], hasValue(temp[4])})	
				--1: id, 2: type, 3: containercount, 4: containersize, 5: material, 6: description
		end						
		end
	 end
end

Improvement to color the line:

local function getColor(number)
	if number < 50 then
		return "rgb(255," .. utils.round(utils.map(number, 0, 40, 100, 255)) .. ",0)"
	else
		return "rgb(" .. utils.round(utils.map(number, 40, 100, 255, 155)) .. ",255,0)"
	end
end

This code cannot work with different containers in one hub.
Please consider specifying the volume/capacity in the name of the hub.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.