Difference between revisions of "Common YOLOL"
(Undo revision 32412 by Scrapper 101 (talk) →Removing working code snippets and explanations for the reason that generator scripts as a whole may or may not work anymore is not in line with Editing Rule regarding speculation) Tag: Undo |
(→Tweakable Generator Script: Unified and cleaned up various tweakable fuel rate scripts) |
||
| (32 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
A collection of small common scripts meant to be easily copied and understood for the [[ | A collection of small common scripts meant to be easily copied and understood for the [[YOLOL]] beginner. | ||
''This page is a | ''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. | |||
''<br/>Note: The [[Laborer Module]] ship rewarded during the tutorial has these fields renamed by default to: <code>Generator</code> and <code>Battery_1</code>'' | |||
==="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. | |||
===Tweakable Generator Script=== | |||
This script is tweakable to your ship configuration and also by an on/off button and/or override lever. Field renamings are those of the default Laborer, except for the :FCRL field. This field needs a new name so that the script can control the fuel rate, instead of the Generator button. | |||
This script is tweakable to your ship configuration. Field | |||
MaxBattery=20000 // total capacity | MaxBattery=20000 // total capacity | ||
| Line 75: | Line 36: | ||
f=MaxBattery l=LowBattery e=MinBattery // no need to change these | f=MaxBattery l=LowBattery e=MinBattery // no need to change these | ||
r=(h-c)/(f-e) z=h-r*l a=r*(f-l) // reboot: remove "goto9" briefly | r=(h-c)/(f-e) z=h-r*l a=r*(f-l) // reboot: remove "goto9" briefly | ||
y=: | y=:Generator-z-r*(:Battery_1+:Battery_2)+c*(y>c)+a*(y>0) :FCRL=y goto9 | ||
It is assumed that | It is assumed that specific YOLOL fields are renamed: | ||
{| class="wikitable" | |||
|+ Renamed fields | |||
|- | |||
! Ship Part !! Old YOLOL field name (Laborer in parenthesis) !! New YOLOL field name | |||
|- | |||
| On/Off Button || ButtonState (Generator) || Generator | |||
|- | |||
| First Battery || StoredBatteryPower (Battery_1) || Battery_1 | |||
|- | |||
| Second Battery || StoredBatteryPower (Battery_2) || Battery_2 | |||
|- | |||
| Fuel Chamber || FuelChamberUnitRateLimit (Generator) || FCRL | |||
|- | |||
| Override Lever (optional) || LeverState || Generator | |||
|} | |||
It is assumed that specific YOLOL fields have the specific values below. The on/off button is already set up in the basic laborer. | |||
{| class="wikitable" | {| class="wikitable" | ||
! Ship Part !! | |+ Fixed field values | ||
|- | |||
! Ship Part !! YOLOL field name !! Fixed field value (Laborer default in parenthesis) | |||
|- | |- | ||
| | | On/Off Button || ButtonOnStateValue|| 100 (100) | ||
|- | |- | ||
| | | On/Off Button || ButtonOffStateValue|| 0 (0) | ||
|- | |- | ||
| | | On/Off Button || ButtonStyle || 1 (1) | ||
|- | |- | ||
| | | Override Lever (optional) || LeverMinOutput || 0 | ||
|- | |- | ||
| | | Override Lever (optional) || LeverMaxOutput || 200 | ||
|- | |- | ||
| | | Override Lever (optional) || LeverCenteringSpeed || 0 | ||
|} | |} | ||
==[[Material point scanner | ==[[Flight control unit]]== | ||
===Slow Mode=== | |||
Requires to modify the lever bound to '''"FcuForward"''' which shall be renamed '''"Fwd"''' and a button with '''"ButtonState"''' renamed '''"Slow"''' and '''"ButtonStyle"''' set to '''"1"'''. This script is useful when you need more manoeuvrability but have too much forward thrust (e.g. while mining or docking). | |||
''Note: Replace '''"X"''' with the number you want to substract from the percentage rate of your main thrusters. Example: A "X" of 80 means you'll have 100-80=20% of maximum thrust.'' | |||
:FcuForward=:Fwd/100*(100-(X*:Slow)) goto1 | |||
===Single Forward/Backward Lever=== | |||
Requires a center lever bound to '''"FcuForward"'''. | |||
:FcuBackward=-:FcuForward goto1 | |||
''Note: Eventually you might want to modify forward and backward individually (e.g. slow mode), in which case you'll need a lever unbound to any instead (name it '''"FwdBwd"'' for example) and 2 YOLOL chips.'' | |||
:FcuForward=:FwdBwd goto1 | |||
:FcuBackward=-:FwdBwd goto1 | |||
==[[Material point scanner]]== | |||
===Material Point Scanner Script=== | ===Material Point Scanner Script=== | ||
Requires | Requires 2 displays for '''"Material"''' and '''"Volume"''', 2 buttons to toggle '''"Active"''' and '''"Scan"''' and a third one with '''"ButtonState"''' renamed '''"Next"''' and '''"ButtonStyle"''' set to '''"1"'''. | ||
:Index=(:Index+:Next)*(:Index<:ScanResults) :Next=0 | :Index=(:Index+:Next)*(:Index<:ScanResults) :Next=0 | ||
:Material=:Material :Volume=:Volume goto1 | :Material=:Material :Volume=:Volume goto1 | ||
| Line 106: | Line 99: | ||
This is a modified version of the above script so it can be used when the scanner is '''"Active"''' without the need of any additional buttons. | This is a modified version of the above script so it can be used when the scanner is '''"Active"''' without the need of any additional buttons. | ||
''Note: launching a new scan reinitialize the index to '''"0"'''.'' | ''Note: launching a new scan reinitialize the index to '''"0"'''.'' | ||
:Scan=1 | :Scan=1 | ||
//Pause | //Pause | ||
| Line 113: | Line 105: | ||
:Material=:Material :Volume=:Volume goto1 | :Material=:Material :Volume=:Volume goto1 | ||
==[[Mining laser | ==[[Mining laser]]== | ||
===Pulsed 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 " | 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 | :MiningLaserOn=(1-:MiningLaserOn)*:Mining goto1 | ||
===Configurable Pulsed Mining Laser=== | ===Configurable Pulsed Mining Laser=== | ||
Similar to the previous script but with configurable timers for the " | Similar to the previous script but with configurable timers for the "on" and "off" phases of the laser. | ||
''Note: Each phase is calculated in | ''Note: Each phase is calculated in number of YOLOL "tick" (0.2sec). Replace '''"X"''' with the duration of "on" and '''"Y"''' with the duration of "off". Example: A "X" of "3" means the "on" phase will last 3*0.2=0.6sec.'' | ||
On=X Off=Y :MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto1 | |||
On= | |||
==[[Navigation receivers | ==[[Navigation receivers]]== | ||
===Received Signal Display=== | ===Received Signal Display=== | ||
Requires a text panel with '''"PanelValue"''' renamed '''"Nav"'''. | Requires a text panel with '''"PanelValue"''' renamed '''"Nav"'''. | ||
if :SignalStrength>0 then goto2 else :Nav="No Signal" goto1 end | if :SignalStrength>0 then goto2 else :Nav="No Signal" goto1 end | ||
:Nav=:Message+"\n"+(1000000-:SignalStrength)/1000+"km" goto1 | :Nav=:Message+"\n"+(1000000-:SignalStrength)/1000+"km" goto1 | ||
==[[Ship transponder]]== | |||
==[[Ship transponder | |||
===Leaving Safezone Warning=== | |||
Requires an active transponder and either a warning button or a safety lid button. | |||
:ButtonEnableBlink=1-:InsideSafeZone goto1 | :ButtonEnableBlink=1-:InsideSafeZone goto1 | ||
[[Category:Networks|Common YOLOL]] | [[Category:Networks|Common YOLOL]] | ||
Revision as of 05:01, 9 December 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.
Tweakable Generator Script
This script is tweakable to your ship configuration and also by an on/off button and/or override lever. Field renamings are those of the default Laborer, except for the :FCRL field. This field needs a new name so that the script can control the fuel rate, instead of the Generator button.
MaxBattery=20000 // total capacity LowBattery=0.99*MaxBattery // start charging below 99% MinBattery=0.20*MaxBattery // max charge rate below 20% MaxGenerator=100 // max fuel rate MinGenerator=2 // min fuel rate (near 100% charge) h=MaxGenerator c=MinGenerator // auxiliary variables, f=MaxBattery l=LowBattery e=MinBattery // no need to change these r=(h-c)/(f-e) z=h-r*l a=r*(f-l) // reboot: remove "goto9" briefly y=:Generator-z-r*(:Battery_1+:Battery_2)+c*(y>c)+a*(y>0) :FCRL=y goto9
It is assumed that specific YOLOL fields are renamed:
| Ship Part | Old YOLOL field name (Laborer in parenthesis) | New YOLOL field name |
|---|---|---|
| On/Off Button | ButtonState (Generator) | Generator |
| First Battery | StoredBatteryPower (Battery_1) | Battery_1 |
| Second Battery | StoredBatteryPower (Battery_2) | Battery_2 |
| Fuel Chamber | FuelChamberUnitRateLimit (Generator) | FCRL |
| Override Lever (optional) | LeverState | Generator |
It is assumed that specific YOLOL fields have the specific values below. The on/off button is already set up in the basic laborer.
| Ship Part | YOLOL field name | Fixed field value (Laborer default in parenthesis) |
|---|---|---|
| On/Off Button | ButtonOnStateValue | 100 (100) |
| On/Off Button | ButtonOffStateValue | 0 (0) |
| On/Off Button | ButtonStyle | 1 (1) |
| Override Lever (optional) | LeverMinOutput | 0 |
| Override Lever (optional) | LeverMaxOutput | 200 |
| Override Lever (optional) | LeverCenteringSpeed | 0 |
Flight control unit
Slow Mode
Requires to modify the lever bound to "FcuForward" which shall be renamed "Fwd" and a button with "ButtonState" renamed "Slow" and "ButtonStyle" set to "1". This script is useful when you need more manoeuvrability but have too much forward thrust (e.g. while mining or docking). Note: Replace "X" with the number you want to substract from the percentage rate of your main thrusters. Example: A "X" of 80 means you'll have 100-80=20% of maximum thrust.
:FcuForward=:Fwd/100*(100-(X*:Slow)) goto1
Single Forward/Backward Lever
Requires a center lever bound to "FcuForward".
:FcuBackward=-:FcuForward goto1
Note: Eventually you might want to modify forward and backward individually (e.g. slow mode), in which case you'll need a lever unbound to any instead (name it '"FwdBwd" for example) and 2 YOLOL chips.
:FcuForward=:FwdBwd goto1
:FcuBackward=-:FwdBwd goto1
Material point scanner
Material Point Scanner Script
Requires 2 displays for "Material" and "Volume", 2 buttons to toggle "Active" and "Scan" and a third one with "ButtonState" renamed "Next" and "ButtonStyle" set to "1".
:Index=(:Index+:Next)*(:Index<:ScanResults) :Next=0 :Material=:Material :Volume=:Volume goto1
Automatic Material Point Scanner Script
This is a modified version of the above script so it can be used when the scanner is "Active" without the need of any additional buttons. Note: launching a new scan reinitialize the index to "0".
:Scan=1 //Pause :Index=Next Next=(Next+1)*(Next<:ScanResults) :Material=:Material :Volume=:Volume goto1
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 configurable timers for the "on" and "off" phases of the laser. Note: Each phase is calculated in number of YOLOL "tick" (0.2sec). Replace "X" with the duration of "on" and "Y" with the duration of "off". Example: A "X" of "3" means the "on" phase will last 3*0.2=0.6sec.
On=X Off=Y :MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto1
Received Signal Display
Requires a text panel with "PanelValue" renamed "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
Requires an active transponder and either a warning button or a safety lid button.
:ButtonEnableBlink=1-:InsideSafeZone goto1