Space Engineers

Space Engineers

Not enough ratings
Farmhand - Farm Manager Guide
By Duke Skyloafer
A detailed usage guide for Farmhand, a programmable block script for automating farms.
   
Award
Favorite
Favorited
Unfavorite
Features

Farmhand is a script to help ensure high yields and automate harvesting. It includes several features for alerting and triggering events. It's a perfect addition to your automated harvesting rigs.

Changes the lights on the farm plots to indicate the status of the crop. This is configurable, but these are the defaults:
  • Dark Purple: Nothing planted
  • White: Plant is growing
  • Green: Plant is ready to harvest
  • Red: Plant is dead
  • Blinking White: Farm plot is low on water
Tracks the amount of ice in irrigation systems
Tracks the amount of water in the farm plots
Tracks the air/pressurization status using an air vent
Triggers timer blocks when certain events occur
Setup
Load the script into a programmable block. You should see a summary of tracked blocks on the programmable block's screen.

Take all the blocks you want to track and put them in a group together. This include farm plots, irrigation systems, air vents, and timer blocks. All blocks are technically optional.

Next, add the tag [FarmLCD] to any LCD Panels or Control Seats/Cockpits. Then, go into the Custom Data of the block and add the group name. This LCD Panel/Control Seat/Cockpit will now monitor that group. You can add as many LCDs to a group as you want, and you can have as many groups as you want.

(Optional) If you only want to track one group and don't want to see a readout on a screen, you can add a single group to the Custom Data of the programmable block. This will still control farm plot lights and trigger timers, but it can only track one group.

Congratulations, setup is now complete!
Compatible Blocks
The Programmable Block
The programmable block running the script contains some script-wide config in it's custom data. In the Custom Data, you can also configure farm plot light colors and low water and ice threshold levels. If you have multiple farms on the same grid, you only need one programmable block to manage all of them.

Farm Plots
The script will show the status of the the crop in each plot, and how much yield is available. It will change color to react to different states: Empty (available), growing, fully grown (harvestable), and dead.

It also tracks the water level in each plot and will show an alert and blink the farm plot lights if any get low.

Irrigation Systems
The script will tell you how full each irrigation system is, and will alert when you're running low on ice.

LCD Panels
To use a Text/LCD Panel, add the tag [FarmLCD] to it's name. Then add the group name you want to track to the Custom Data. You can choose to show and hide different categories of data, and you can choose to hide the animated header. Just be aware that if you hide the header, you may not notice if the script stops updating for some reason (like if the programmable block was damaged).

Cockpits & Control Seats
These work basically the same as LCD Panel blocks, except instead of true/false for the categories, you set the index of the screen you want that category to appear on. Screens indexes start with 0, which is the default. You can still set it to "false" to hide the category entirely.

Air Vents
You can add multiple vents to the group, but the script will only use the first one it finds. It uses thew air vent to detect the state of the atmosphere.

Timer Blocks
Timers can be triggered when certain events occur. Timers can respond to more than one event, however you want to do it. Open a timer's Custom Data and set any events to true to trigger on that event.
Customizing - Programmable Block
The programmable block allows you to customize some program-wide configuration. You will find all of these options inside the Custom Data:

Group Name
This is a legacy setting from an earlier version of the script. You can still use it, but it's recommended to use LCDs to define the groups instead.

You can put a single group name in this entry, and the script will still run the farm plot lights and trigger timer blocks, but it will not display anything until you tag an LCD Panel block or Control Seat block and set it up.

Colors
The colors on the farm plots are configurable. They are defined as a comma-separated string of integers in the format of "R,G,B" where R is the red value, G is the green value, and B is the blue value. You can manually set the other light values for farm plots (intensity, radius, etc) in the terminal like normal.

If you enter an RGB value incorrectly, for example if you just entered the word "Red," the lights will be set to black.

Plot Empty Color
RGB color for empty farm plots (default: 80,0,170)

Plant Alive Color
RGB color for growing plants (default: 255,255,255)

Plant Ready Color
RGB color for ready-to-harvest plants (default: 0,255,185)

Plant Dead Color
RGB color for dead plants (default: 255,0,100)

Alerting Thresholds
When the value being monitored dips below the configured threshold, the alert will trigger. This will show up on LCDs and trigger timer blocks. Each of these are a percent from 0% to 100%, expressed as decimals from 0.0 to 1.0. Anything above or below this range will be set to the nearest value in range. Anything entered that isn't a number will result in the default value being used.

Ice Low Threshold
Ice level threshold (0.0-1.0) that triggers low ice alerts and events (default: 0.2)

Water Low Threshold
Water level threshold (0.0-1.0) that triggers low water alerts and blinking lights (default: 0.5)

Health Low Threshold
Health threshold for farm plot plants (0.0-1.0) that triggers low health/dying alerts. By default, it will alert you as soon as a plant's health drops at all (default: 1.0)
Customizing - Timer Blocks & Events
The timer block allows you to customize which events will cause this timer to trigger. You will find all of these options inside the Custom Data:

Trigger Immediately
Setting this to true will trigger the timer immediately. Setting it to false will start the countdown. This setting applies to all events in that timer.

Event Triggers
Events come in pairs that are essential "condition is met" and "condition is no longer met." Positive and negative conditions. The timers trigger when conditions cross the boundary from "met" to "not met" to "met" again. Might seem simple, but when dealing with groups of things, it may not be clear exactly what "condition no longer meant" means.

On Water Low/On Water Not Low
The positive condition is met when any farm plot is low on water. The negative condition is met when low plots are refilled and all plots are above the water threshold. The threshold is configurable in the programmable block's Custom Data.

On Ice Low/On Ice Not Low
The positive condition is met when any irrigation system is low on ice. The negative condition is met when low irrigation systems are refilled and all irrigation systems are above the ice threshold. The threshold is configurable in the programmable block's Custom Data.

On Pressurized/On Depressurized
The positive condition is met when a room becomes fully pressurized. Even if the room is air-tight, this event will not trigger until the air vent reports full pressurization. The negative is met as soon as the air vent starts reporting that the room is depressurizing or is depressurized.

On Crop Ready/On Crop Not Ready
The positive condition is met once any farm plot is ready for harvest. The negative is met once all farm plots have been harvested and none are ready.

On All Crops Ready/On All Crops Not Ready
The positive occurs once all planted farm plots are ready for harvest. This does not account for any unplanted farm plots. The negative occurs if you plant an additional plot after the positive has already triggered, because now there are growing plots that are not ready for harvest, so not all planted plots are ready. If you want to trigger when all plots have been harvested, use On Crop Not Ready.

On Crop Dying/On Crop Not Dying
The positive condition is met once any farm plot's health drops below the configured threshold. The negative is met once all dying farm plots have either recovered back above the threshold or have fully died.

On Crop Dead/On Crop Not Dead
The positive condition is met once any farm plot dies for any reason. The negative is met once all dead farm plots have been cleared.

On Crop Available/On Crop Not Available
The positive condition is met once any farm plot is available for planting. The negative is met once all farm plots have been planted.
Customizing - LCDs, Cockpits, & Control Seats
Before modifying Custom Data for one of these blocks, ensure they are tagged with [FarmLCD] in the name.

To simplify things, I'm just going to refer to Text Panels, LCD Panels, Cockpits, and Control Seats as "LCD Providers" for this portion of the guide.

Group Name
Ensure all the blocks you want to monitor are included in a group and add the group name to this entry. Each LCD Provider can monitor one group.

Header
Shows the animated header on the screen. Be aware that if you turn this off, you may not notice if the script has stopped working, like if the programmable block is damaged or offline.

Display Categories

Show Alerts
Shows information requiring attention. This section will not appear if there are no active alerts.

Show Atmosphere
Shows information related to pressurization. This section will not appear if there are no air vents in the group.

Show Irrigation
Shows irrigation system ice status. This section will not appear if there are no irrigation systems in the group.

Show Yield
Shows current crop status, including the types of crops planted and the number of plots per crop type. When a plot has finished growing, it will show the yield (the number of plants that will be harvested). This section will not appear if no farm plots are planted.