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 (→‎Flight Control Unit: delete useless spaces in scripts)
Tag: Undo
 
(18 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 [[YOLOL]] beginner.
A collection of small common scripts meant to be easily copied and understood for the [[YOLOL|YOLOL]] beginners.


''This page is a WIP. Please contribute to it! (Avoid complex scripts and the renaming of fields.)''
''This page is a "Work In Progress". Don't hesitate to contribute! Just make sure to respect the following rules:
* Avoid complex codes. As said, These must be easily understood by beginners. If you can't simplify your scripts, please add some comments to explain the most technical parts.
* Avoid as possible to modify the [[Device fields|device fields]]. If necessary, it must be specified which field has to be renamed (left column) and/or set to a given value (right column). ''


==[[Flight control unit|Flight Control Unit]]==
==[[Flight control unit|Flight Control Unit]]==


===Single Forward/Backward Lever===
===Single Forward/Backward Lever===
Requires a center lever bound to '''"FcuForward"'''. ''Note: You can easily modify the default regular lever to be used as a center Lever. Just change the "LeverMinOutput" value from 0 to -100.''
Requires a center lever bound to '''"FcuForward"'''. ''Note: You can easily modify the default regular lever from most prebuilt ships and cockpit modules to be used as a center Lever. Just change the '''"LeverMinOutput"''' value from 0 to -100. Also don't forget to modify your control binds ("V" on keyboard by default).''
 
  :FcuBackward=-:FcuForward goto1
  :FcuBackward=-:FcuForward goto1


===Speed Limiter===
===Speed Limiter===
Requires to modify the lever bound to '''"FcuForward"''' which shall be renamed '''"Fwd"''' and another regular lever with '''"LeverState"''' renamed '''"Limiter"'''. This script allow you to set a maximum forward speed to your ship, which is useful when you need more accurate movements (e.g. while mining or docking).
Requires to modify the lever bound to '''"FcuForward"''' which shall be renamed '''"Fwd"''' and another regular lever with '''"LeverState"''' renamed '''"Limiter"'''. This script allow you to set a maximum forward speed to your ship, which is useful when you need more accurate movements (e.g. while mining or docking).
  :FcuForward=:Fwd/100*:Limiter goto1
  :FcuForward=:Fwd/100*:Limiter goto1
''Note: If you already modified your '''"FcuFoward"''' lever to be used as a '''"Single Forward/Backward Lever"''' (see above), you can use the '''"Backward"''' lever made useless as the '''"Limiter"''' lever. Just make sure you have '''"FcuForward"''' renamed '''"FwdBwd"''' instead so you can modify forward and backward thrust individually. This way your YOLOL scripts should be written as follows:''
''Note: If you already modified your '''"FcuFoward"''' lever to be used as a '''"Single Forward/Backward Lever"''' (see above), you can use the '''"Backward"''' lever made useless as the '''"Limiter"''' lever. Just make sure you have '''"FcuForward"''' renamed '''"FwdBwd"''' instead so you can modify forward and backward thrust individually. This way your YOLOL scripts should be written as follows:''
  :FcuForward=:FwdBwd/100*:Limiter goto1
  :FcuForward=:FwdBwd/100*:Limiter goto1


Line 19: Line 25:
===Turtle Mode===
===Turtle Mode===
Similar to the previous script but with a button instead of a lever. '''"ButtonState"''' should be renamed '''"Turtle"''' and '''"ButtonStyle"''' set to '''"1"'''. In addition set the '''"ButtonOffStateValue"''' to '''"100"''' and the '''"ButtonOnStateValue"''' to the desired speed reduction. For example having '''"30"''' means 30% of maximum speed when the button is active.
Similar to the previous script but with a button instead of a lever. '''"ButtonState"''' should be renamed '''"Turtle"''' and '''"ButtonStyle"''' set to '''"1"'''. In addition set the '''"ButtonOffStateValue"''' to '''"100"''' and the '''"ButtonOnStateValue"''' to the desired speed reduction. For example having '''"30"''' means 30% of maximum speed when the button is active.
  :FcuForward=:Fwd/100*:Turtle goto1
  :FcuForward=:Fwd/100*:Turtle goto1


==[[Fuel chamber|Fuel Chamber]]==
==[[Fuel chamber|Fuel Chamber]]==
Ships will require enough batteries to act as a buffer for the generator spool up time.


==="Standard" Generator Script===
The following scripts are made to be used with the ship "[[Laborer module|Laborer Module]]" rewarded during the tutorials. To make it compatible with other prebuilt or own-made ships, refer to the table below for the corresponding modifications in the [[Device fields|device fields]]. ''Note: Most scripts make the "Generator" button irrelevant as it replace its use. Some may make another use of it.''
:FuelChamberUnitRateLimit=100-:StoredBatteryPower/100 goto 1
 
{| class="wikitable"
! Ship Part !! Default Field Name !! Laborer Module Field Name
|-
| Hybrid Button || ButtonState || Generator
|-
| Fuel Chamber || FuelChamberUnitRateLimit || Generator
|-
| First Battery || StoredBatteryPower || Battery_1
|-
| Second Battery || StoredBatteryPower || Battery_2
|}
 
Also, ships will require enough batteries to act as buffers during the generator spool up time. ''Note: When in use, all batteries discharge at the same rate. The more batteries you have, the slower the discharge is.''


Makes the fuel chambers' rate limit follow the battery charge inversely.
===Gradual Generator Script===
''<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>''
Makes the fuel rate limit of the fuel chamber inversely proportional to the charge level of the batteries.


==="Alternative" Generator Script===
:Generator=100-:Battery_1/100 goto1


An alternative script that will keep the batteries fuller.
Alternatively, the script below will keep the batteries fuller by setting the fuel rate limit to its maximum when batteries are below 90% of charge.


  :FuelChamberUnitRateLimit=1000-:StoredBatteryPower/10 goto 1
  :Generator=1000-:Battery_1/10 goto1


===Settable on/off Generator flag===
Additionally, you can use the "Generator" button by renaming it "Eco" so it switch fuel saving on and off with the following script. Useful for more power consuming activities like mining.
:Generator=22*(:Battery_1>5000)*(:Battery_1<9999)+0.001 goto1


:Generator=100-:Eco*:Battery_1/100 goto1


5000 and 9999 are the start-charging and stop-charging levels. 22% is just enough charge to run the stock two box thrusters.
===Flagged Generator Script===
This script set the fuel rate limit to 25% (just enough to supply 2 box thrusters with a bit of spare charge) if the level of the batteries is below 9999 and adding 50% if below 5000. 0.001% is enough fuel rate to let the generator "sleep" when the ship stand still and the batteries are full.


===Tweakable Generator Script===
:Generator=25*(:Battery_1<9999)+50*(:Battery_1<5000)+0.001 goto1


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.
===Advanced Generator Script===
This script is tweakable to your ship configuration. Field names are those of the Laborer Module, except for the '''"Generator"''' button which should be renamed '''"PWR"''' so the script can control the fuel rate while the button still being functional. Optionally you can add an override lever with '''"LeverState"''' renamed '''"PWR"''' as well.


  MaxBattery=20000          // total capacity
  MaxBattery=20000          // total capacity
Line 54: Line 75:
  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=:Generator-z-r*(:Battery_1+:Battery_2)+c*(y>c)+a*(y>0) :FCRL=y goto9
  y=:PWR-z-r*(:Battery_1+:Battery_2)+c*(y>c)+a*(y>0) :Generator=y goto9


It is assumed that specific YOLOL fields are renamed:
It is assumed that the following device fields are set as explained (''Note: The "PWR" button is already set up in the Laborer Module''):
{| 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"
|+ Fixed field values
! Ship Part !! Field Name !! Set Field value
|-
! Ship Part !! YOLOL field name !! Fixed field value (Laborer default in parenthesis)
|-
|-
| On/Off Button || ButtonOnStateValue|| 100 (100)
| "PWR" Button || ButtonOnStateValue|| 100
|-
|-
| On/Off Button || ButtonOffStateValue|| 0 (0)
| "PWR" Button || ButtonOffStateValue|| 0  
|-
|-
| On/Off Button || ButtonStyle || 1 (1)
| "PWR" Button || ButtonStyle || 1
|-
|-
| Override Lever (optional) || LeverMinOutput || 0  
| "PWR" Lever (optional) || LeverMinOutput || 0  
|-
|-
| Override Lever (optional) || LeverMaxOutput || 200  
| "PWR" Lever (optional) || LeverMaxOutput || 200  
|-
|-
| Override Lever (optional) || LeverCenteringSpeed || 0
| "PWR" Lever (optional) || LeverCenteringSpeed || 0
|}
|}


Line 95: Line 98:


===Material Point Scanner Script===
===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"'''.
Requires two displays for '''"Material"''' and '''"Volume"''', two buttons to toggle the '''"Active"''' and '''"Scan"''' fields of the scanner, and a third button 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 102: Line 106:
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 109: Line 114:


==[[Mining laser|Mining Laser]]==
==[[Mining laser|Mining Laser]]==
''Note: [[Mining laser|Mining Lasers]] were updated to have an activation cost, which is why pulsing lasers is not economic anymore.''
===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.


===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
  :MiningLaserOn=(1-:MiningLaserOn)*:Mining goto1


===Configurable Pulsed Mining Laser===
===Configurable Pulsed Mining Laser===
Similar to the previous script but with configurable timers for the "On" and "Off" phases of the 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). So in the example, the "On" phase last 2*0.2=0.4sec and the "Off" phase 3*0.2=0.6 sec, which makes the power comsumption just a bit lower than the power production of a generator module (= one fuel chamber and three generator units, all in tier 1).''
''Note: Each phase is calculated in a number of YOLOL "tick" (0.2sec). So in the example, the "On" phase last 2*0.2=0.4sec and the "Off" phase 3*0.2=0.6 sec, which makes the power comsumption just a bit lower than the power production of a regular generator module (= one fuel chamber and three generator units, all in tier 1).''
 
  On=2 Off=3 :MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto1
  On=2 Off=3 :MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto1


Line 123: Line 130:
===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
Line 128: Line 136:
==[[Ore collector|Ore Collector]]==
==[[Ore collector|Ore Collector]]==


===Mining Laser/ Ore Collector Switching===
===Mining Laser/ Ore Collector Swapping Power===
Requires a button with '''"ButtonState"''' renamed '''"Collecting"''' and '''"ButtonStyle"''' set to '''"1"'''. Reduces power consumption by switching ore collector "On" only if the button is active And the mining laser is "Off". ''Note: this script works best alongside the "Pulsed Mining Laser" scripts.''
Requires a button with '''"ButtonState"''' renamed '''"Collecting"''' and '''"ButtonStyle"''' set to '''"1"'''. Reduces power consumption by switching ore collector "On" only if the button is active And the mining laser is "Off". ''Note: this script works best alongside the "Pulsed Mining Laser" scripts.''
  :ToggleOn=(1-:MiningLaserOn)*:Collecting goto1
  :ToggleOn=(1-:MiningLaserOn)*:Collecting goto1


Line 135: Line 144:


===Outside Safezone Warning===
===Outside Safezone Warning===
Requires an active transponder and either a warning button or a safety lid button. The button blink whenever you're outside of the safe zone. ''Note: the button needs to be On in order to blink.''
Requires an active transponder and either a warning button or a safety lid button. The button blink whenever you're outside of the safe zone. ''Note: the button needs to be active in order to blink.''
 
  :ButtonEnableBlink=1-:InsideSafeZone goto1
  :ButtonEnableBlink=1-:InsideSafeZone goto1


===Stations Building Availability===
===Stations Building Availability===
Same as the previous one, but the button blink wherever you're allowed to build a station.
Same as the previous one, but the button blink wherever you're allowed to build a station.
  :ButtonEnableBlink=:StationsAllowed goto1
  :ButtonEnableBlink=:StationsAllowed goto1


[[Category:Networks|Common YOLOL]]
[[Category:Networks|Common YOLOL]]

Latest revision as of 06:04, 4 July 2024

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

This page is a "Work In Progress". Don't hesitate to contribute! Just make sure to respect the following rules:

  • Avoid complex codes. As said, These must be easily understood by beginners. If you can't simplify your scripts, please add some comments to explain the most technical parts.
  • Avoid as possible to modify the device fields. If necessary, it must be specified which field has to be renamed (left column) and/or set to a given value (right column).

Flight Control Unit

Single Forward/Backward Lever

Requires a center lever bound to "FcuForward". Note: You can easily modify the default regular lever from most prebuilt ships and cockpit modules to be used as a center Lever. Just change the "LeverMinOutput" value from 0 to -100. Also don't forget to modify your control binds ("V" on keyboard by default).

:FcuBackward=-:FcuForward goto1

Speed Limiter

Requires to modify the lever bound to "FcuForward" which shall be renamed "Fwd" and another regular lever with "LeverState" renamed "Limiter". This script allow you to set a maximum forward speed to your ship, which is useful when you need more accurate movements (e.g. while mining or docking).

:FcuForward=:Fwd/100*:Limiter goto1

Note: If you already modified your "FcuFoward" lever to be used as a "Single Forward/Backward Lever" (see above), you can use the "Backward" lever made useless as the "Limiter" lever. Just make sure you have "FcuForward" renamed "FwdBwd" instead so you can modify forward and backward thrust individually. This way your YOLOL scripts should be written as follows:

:FcuForward=:FwdBwd/100*:Limiter goto1
:FcuBackward=-:FwdBwd goto1

Turtle Mode

Similar to the previous script but with a button instead of a lever. "ButtonState" should be renamed "Turtle" and "ButtonStyle" set to "1". In addition set the "ButtonOffStateValue" to "100" and the "ButtonOnStateValue" to the desired speed reduction. For example having "30" means 30% of maximum speed when the button is active.

:FcuForward=:Fwd/100*:Turtle goto1

Fuel Chamber

The following scripts are made to be used with the ship "Laborer Module" rewarded during the tutorials. To make it compatible with other prebuilt or own-made ships, refer to the table below for the corresponding modifications in the device fields. Note: Most scripts make the "Generator" button irrelevant as it replace its use. Some may make another use of it.

Ship Part Default Field Name Laborer Module Field Name
Hybrid Button ButtonState Generator
Fuel Chamber FuelChamberUnitRateLimit Generator
First Battery StoredBatteryPower Battery_1
Second Battery StoredBatteryPower Battery_2

Also, ships will require enough batteries to act as buffers during the generator spool up time. Note: When in use, all batteries discharge at the same rate. The more batteries you have, the slower the discharge is.

Gradual Generator Script

Makes the fuel rate limit of the fuel chamber inversely proportional to the charge level of the batteries.

:Generator=100-:Battery_1/100 goto1

Alternatively, the script below will keep the batteries fuller by setting the fuel rate limit to its maximum when batteries are below 90% of charge.

:Generator=1000-:Battery_1/10 goto1

Additionally, you can use the "Generator" button by renaming it "Eco" so it switch fuel saving on and off with the following script. Useful for more power consuming activities like mining.

:Generator=100-:Eco*:Battery_1/100 goto1

Flagged Generator Script

This script set the fuel rate limit to 25% (just enough to supply 2 box thrusters with a bit of spare charge) if the level of the batteries is below 9999 and adding 50% if below 5000. 0.001% is enough fuel rate to let the generator "sleep" when the ship stand still and the batteries are full.

:Generator=25*(:Battery_1<9999)+50*(:Battery_1<5000)+0.001 goto1

Advanced Generator Script

This script is tweakable to your ship configuration. Field names are those of the Laborer Module, except for the "Generator" button which should be renamed "PWR" so the script can control the fuel rate while the button still being functional. Optionally you can add an override lever with "LeverState" renamed "PWR" as well.

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=:PWR-z-r*(:Battery_1+:Battery_2)+c*(y>c)+a*(y>0) :Generator=y goto9

It is assumed that the following device fields are set as explained (Note: The "PWR" button is already set up in the Laborer Module):

Ship Part Field Name Set Field value
"PWR" Button ButtonOnStateValue 100
"PWR" Button ButtonOffStateValue 0
"PWR" Button ButtonStyle 1
"PWR" Lever (optional) LeverMinOutput 0
"PWR" Lever (optional) LeverMaxOutput 200
"PWR" Lever (optional) LeverCenteringSpeed 0

Material Point Scanner

Material Point Scanner Script

Requires two displays for "Material" and "Volume", two buttons to toggle the "Active" and "Scan" fields of the scanner, and a third button 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

Note: Mining Lasers were updated to have an activation cost, which is why pulsing lasers is not economic anymore.

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 a number of YOLOL "tick" (0.2sec). So in the example, the "On" phase last 2*0.2=0.4sec and the "Off" phase 3*0.2=0.6 sec, which makes the power comsumption just a bit lower than the power production of a regular generator module (= one fuel chamber and three generator units, all in tier 1).

On=2 Off=3 :MiningLaserOn=(T<On)*:Mining T++ T*=T<(On+Off) goto1

Navigation Receiver

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

Ore Collector

Mining Laser/ Ore Collector Swapping Power

Requires a button with "ButtonState" renamed "Collecting" and "ButtonStyle" set to "1". Reduces power consumption by switching ore collector "On" only if the button is active And the mining laser is "Off". Note: this script works best alongside the "Pulsed Mining Laser" scripts.

:ToggleOn=(1-:MiningLaserOn)*:Collecting goto1

Ship Transponder

Outside Safezone Warning

Requires an active transponder and either a warning button or a safety lid button. The button blink whenever you're outside of the safe zone. Note: the button needs to be active in order to blink.

:ButtonEnableBlink=1-:InsideSafeZone goto1

Stations Building Availability

Same as the previous one, but the button blink wherever you're allowed to build a station.

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