Sb forum speech.png DiscordLink.png FacebookLink.png RedditLink.png SteamLink.png TwitterLink.png YoutubeLink.png

Difference between revisions of "Common YOLOL"

From Starbase wiki
Jump to navigation Jump to search
m
m
Line 127: Line 127:


==[[Ship transponder]]==
==[[Ship transponder]]==
===Leaving Safezone Warning===
===Leaving Safezone Warning===
This script require an active transponder and either a warning button or a safety lid button.
This script requires an active transponder and either a warning button or a safety lid button.
  :ButtonEnableBlink = 1 - :InsideSafeZone goto 1
  :ButtonEnableBlink=1-:InsideSafeZone goto1

Revision as of 23:03, 8 October 2021

A collection of small common scripts meant to be easily copied and understood for the YOLOL beginner.

This page is a WIP. Please contribute to it! (Avoid complex scripts and the renaming of fields.)

Fuel chamber

Ships will require enough batteries to act as a buffer for the generator spool up time.

"Standard" Generator Script

:FuelChamberUnitRateLimit=100-:StoredBatteryPower/100 goto 1

Makes the fuel chambers' rate limit follow the battery charge inversely.
Note: The Laborer Module ship rewarded during the tutorial has these fields renamed by default to: Generator and Battery_1

"Alternative" Generator Script

An alternative script that will keep the batteries fuller.

:FuelChamberUnitRateLimit=1000-:StoredBatteryPower/10 goto 1

Settable on/off Generator flag

c=(c<1)*(:Battery_1<5000)+c*(:Battery_1<9999) :Gen=c*22+0.001 goto 1

Fitting this code on the Laborer Module requires renaming at least one device. (here the Generator was renamed Gen)

5000 and 9999 are the start-charging and stop-charging levels. 22 is just enough charge to run the stock two box thrusters.

Generator Script (Basic YOLOL Chip)

This YOLOL script is inspired by the standard generator script and is further optimized. You can set from which amount of stored battery power the generator should generate less compared to the stored battery power.

It is assumed that specific YOLOL fields are renamed:

Ship Part Old YOLOL field name New YOLOL field name
Every Fuel Chamber FuelChamberUnitRateLimit Gen
One Rechargeable Battery StoredBatteryPower Bat

Depending on the amount of batteries and the amount of generators, a higher or lower value can be used for the variable "a" in the script. A too high value leads to the fact that the algorithm cannot find an optimal balance for the FuelChamberUnitRateLimit/Gen.

Generator Script

// Variables for Tweaking
a = 9500 // If Battery Amount is lower than this, Gen is 100%
// Static variables and precalculation
c = 10000 // Max Stored Battery Power
d = 100 // 100%
e = (c-a)/d
// Final Generator Scriptline
:Gen=((:Bat<a)*d)+((:Bat>a)*((:Bat-c)*-1)/e) goto 8

Generator Script with On/Off Button and Minimum Power Production

If the battery consumption is very high and the amount of rechargeable batteries is not enough until the generator produces enough power, you should consider using the following version of the script.

Use a Hybrid-Button with the following field names and values configured:

Name Value
On 0
ButtonOnStateValue 1
ButtonOffStateValue 0
ButtonStyle 1

The variable b can be used to set the minimum amount of power that the generators should generate. A too low value, can lead to the fact that the generators do not provide enough power yet and the batteries are already discharged. A too high value leads to the fuel rod consumption during standstill being too high.

// Variables for Tweaking
a = 9500 // If Battery Amount is lower than this, Gen is 100%
b = 10 // If Button is On, Gen will be at least this much
// Static variables and precalculation
c = 10000 // Max Stored Battery Power
d = 100 // 100%
e=(c-a)/d f=(d/b)
// Final Generator Scriptline
:Gen=:On*(((:Bat<a)*d)+((:Bat>a)*(((:Bat-c)*-1)+(:Bat-a)/f)/e)) goto 9

Flight control unit

Single lever forward/backward script (Basic YOLOL Chip)

Note: This script assumes you have a center lever bound to FcuForward

Default device fields

:FcuBackward=-:FcuForward goto 1

Material point scanner

Material Point Scanner Script

Note: Additionally to two output panels for "Material" and "Volume" and two buttons to toggle "Active" and "Scan" install a third button and rename "ButtonState" to "Next" and set its "ButtonStyle" to 1.

:Material=:Material :Volume=:Volume
:Index=(:Index+:Next)*(:Index<:ScanResults) :Next=0 goto 1

Continuous Material Point Scanner Script

This is a modified version of the above script so it can be used when the scanner is on without the need of any additional buttons. Note: launching a new scan reinitialize the index to 0, so the script had to be changed a bit furthermore.

:Next=0
:Scan=1
//Pause
:Next=(:Next+1)*(:Next<:ScanResults)
:Index=:Next
:Material=:Material :Volume=:Volume goto 2

Mining laser

Pulsed Mining Laser

Requires a button with "ButtonState" renamed "Mining" and "ButtonStyle" set to "1". Reduces power consumption by continuously switching mining laser "on" and "off" while the button is active.

:MiningLaserOn=(1-:MiningLaserOn)*:Mining goto1

Configurable Pulsed Mining Laser

Similar to the previous script but with a configurable timer for the "on" and "off" duration of the laser. Note: Each phase is calculated in number of YOLOL "tick" (0.2sec). Change "X" by the duration of "on" and "Y" by the duration of "off".

T=0 On=X Off=Y 
:MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto2

Navigation receivers

Receiver Signal Display

Using a display named Nav

if :SignalStrength>0 then goto2 else :Nav="No Signal" goto1 end
:Nav=:Message+"\n"+(1000000-:SignalStrength)/1000+" km" goto1

Ship transponder

Leaving Safezone Warning

This script requires an active transponder and either a warning button or a safety lid button.

:ButtonEnableBlink=1-:InsideSafeZone goto1
Cookies help us deliver our services. By using our services, you agree to our use of cookies.