Making scripts/Programs more server friendly

Vorg shared this feedback 4 years ago

First, currently servers can set a limit on the number of Programmable blocks. But how many players only have 1 craft or base? Many craft have special functions and many scripts are only used for certain things. Example a wheeled craft which also can fly. Use driving scripts to control wheel system, but assorted thruster control scripts when flying. Vector thrust with thrusters on rotors, or launch scripts that reduce H2 used when leaving a planet are only used while leaving the planet, compass scripts only used when on planets. And none of them used when using base systems. Or if you switch to a mining craft, you don't need the same scripts.

So instead of a limit on the number of PB's per person, make it a limit of the number of active/powered PB's per person. Players can then just switch off the ones not in use allowing for wide options of scripts without having to reload scripts or grind down and rebuild else were.

Also, Take a page from Stationeers. Some programs don't need the power of a PB or the language it uses. Example, solar trackers, power/cargo monitoring, etc.. For these make a new low level PB that uses a simpler machine code like MIPS and has a limit on the number of lines per tick with only 1 command per line. No long complex math code on a single line. Just comments on the same line as code. Also, make it something like a quad core with 4 LPB's in one block to help keep block count down. Call it a QLPB.

Replies (2)


I can get your points.

But for programmable blocks there has to be a limit like "maximum allowed runtime", "maximum script execution time" + some option to set the blocks to a pre-definied schedule time (so it's not getting triggered every second when it's a big script), even with "per person active pb's" it won't be enough

most servers have this thing disabled, and that's for a good reason, just 4-5 Inventory Manager scripts can lead to huge server lags, in this case a simple fixed timer , like ALL programmable blocks the world get triggered at the SAME INTERVAL(1-5min or something is enough for inventory stuff) would give some relief for lag

something like pre-definied scripts would be also awesome, like tested,"lag-free" ones


With the machine code tick based system, server load would be far less. Because it wouldn't matter how big the program is, only a certain number would be done in a give tick. And math would have to be done 1 function at a time. For next/while loops whould not be doable on a single line. Here is an example of a solar tracking program I use in Stationeers which tracks in both axis, resets to sunrise at night, and turns on an aux gen if batteries get too low. It can run through everything in 1 tick and you are only allowed 128 lines per tick. I think total code size is limited to 256 lines. Comment lines and blank lines count against the 128:

# Single Sensor Solar Track & Gen Control 02/05/19
alias SolarPower d0 # Any Solar Panel .Charge
alias SolSensor d1  # Vert Sensor Facing Up/North
alias VBWrite db # Socket .Setting BWrite .Vertical
alias MemHoriz d2 # Mem .Setting BWrite .Horizontal
alias BatRead d3  # Reader Memory Batteries .Ratio
alias SolidGen d4 # Solid Generator .On
alias SGenVent d5 # Gas Gen activate
alias Night r2   # Night Time flag
alias GenVentT r3  # Off timmer for Gen Vent
alias BatLowS r4 # Batt Level Trip for SolidGen
alias BatHigh r5 # Holds High battery level
alias VentTime r6 # Set time vent stays on

# Set Generator Active Levels
move GenVentT 0      # Clear Vent Timmer
move VentTime 10      # Time Vent stays on *2
move BatLowS 0.05    # Set Gen Start Level
move BatHigh 0.25    # Set Gen Stop Level

l r0 SolarPower Charge      # Get Solar Output
brgtz r0 7                  # Have power
brgtz Night 4               # Skip if Night
move Night 1                # Set Night Flag
s MemHoriz Setting -90      # Reset Horiz
s VBWrite Setting 0         # Reset Vert
yield                       # limit to once/tick
j GenCheck                  # Skip Solar
move Night 0                # Clear Night Flag
s SolSensor Mode 1          # Set Horiz Mode
yield                       # Wait for Sensor Setup
l r0 SolSensor SolarAngle   # Get Horiztontal Angle
mul r0 r0 -1                # Invert Angle
s MemHoriz Setting r0       # Write Horiz to Solar
s SolSensor Mode 2          # Set Vert Mode
yield                       # Wait for Sensor Setup
l r0 SolSensor SolarAngle   # Get Verical Angle
sub r0 75 r0                # r0 = 75 - r0
max r0 r0 0             # Clamp to 0|min brlez r0 4
div r0 r0 1.5               # r0 = r0 / 1.5
s VBWrite Setting r0        # Write Vert to Solar

GenCheck:               # Check if gen is needed
l r0 BatRead Setting    # Get battery level
bgtz GenVentT SGenOn    # Jump if Vent on
slt r1 r0 BatLowS       # Check if bat low
blez r1 Main
s SolidGen On r1        # Turn on if low
s SGenVent On r1        # Turn on Active vent
move GenVentT VentTime  # Set vent off timer  ---
j Main
slt r1 r0 BatHigh
s SolidGen On r1        # Turn Gen On/Off
add GenVentT GenVentT r1
sub GenVentT GenVentT 1
bgtz GenVentT Main      # Check Vent Timmer
s SGenVent On 0         # Turn off Vent
j Main

Leave a Comment
Attach a file