This tutorial is set by the author's setting without permission.
This tutorial is a rookie -style tutorial, which is almost meaningless for those who are skilled Lua.Of course, you are also welcome to supplement and correct
After the Create 0.5.1 update, there have been some interfaces for CC: Tweake support.Therefore, we can use CC: Tweaked computers to achieve automatic speed regulation to reduce the effects of load mutations or unstable stress sources.Note that this module only supports ASCII, and does not support Chinese input
First, you need to prepare a stress meter, a speed controller and a computer. The stress watch and the speed controller must contact the computer.
(You can use ordinary gray computers. The advanced computer is to facilitate the demonstration.
Right -click to turn on the computer of the computer. It is recommended to enter the Label Set XXX first (the name you want to give the computer), so that after the removal, you can quickly recognize which computer is in the bag.
Then copy one of the two lines to paste, and return (prompt NO Such Program, first copy the code into the notepad and then copy it out to eliminate the format)
wget https://gitee.com/a1973771383/1973-s-cctweaked-lua-stock/raw/master/startup.luaa
wget https://raw.githubusercontent.com/1973771383/1973-s-cctweaked-lua-stock/main/startup.luaaaa
If the display of the following figure below indicates that the download is successful, the download of the UNKNOWN HOST and others failed.
Regardless of the result, continue to type Edit Startup.Lua
Enter the editing interface. If the file is downloaded as shown in Figure 1, you can skip the steps later until you see this picture again; if it is as shown in Figure 2, continue to follow the operation
Press Ctrl, select save to save (yes, save the empty file directly), and then press ctrl to select exit exit
Type the ID after exiting to get the computer number and label
Remember the computer ID, find the archive file, and open it (use the book or any document/code editor)
Copy the code below in and save
rsc = peripheral.find ("create_rotationSpeedController")Som = Peripheral.find ("Create_stressometer")
if term.iscolour () then
Shell.run ("bg")
Term.setTextColour (colors.orange)
Print ("Auto-Speed-Regulation Activated")
Else Print ("Auto-Speed-Regulation Activated"))
end
Function main ()
Curstress = som.getStress ()
TotalStress = SOM.GetStressCapAcity ()
CURSPEED = RSC.gettargetSpeed ()
If (CURSTRESS ~ = TotalStress) then
Deltastressmult = CURSTRESS/TOTALSTRESS
Pn = CURSPEED/Math.abs (CURSPEED) ABS_TargetSpeed = Math.abs (CURSPEED/DELTASTRSSMult)
If ABS_TARGETSPED> 256 then ABS_TargetSpeed = 256
-Elseif ABS_TargetSpeed <32 THEN ABS_TARGETSPED = 32
End
RSC.SetTargetSpeed (ABS_TargetSpeed*PN)
End
end
Repeat
Main (main ()
Sleep (0.5)
unil false
-Elseif ABS_TARGETSpeed <32 THEN ABS_TARGETSPED = 32 is the content that comes off. You can delete the minimum value of the previous-speed up speed.
Back to the game, enter the list or LS to view the current directory, enter Edit Startup.Lua to open the file just modified
You can see that the file has been edited.(If you want to paste the editor in the game, it can only come one by one)
Then click the power key in the upper left corner of the editor box to turn off the computer and start again
If this is the interface, I see "Auto-Speed-Regulation Activity" without other error instructions that the code has been successfully run.
At this time, the first window is running the startup program. If you want to perform other operations, you can click to switch to the second shell window.
It is recommended that the whole system should not use the speed controller except the power output end here, otherwise the speed regulating system will fail
If you have multiple power systems in your archive, you can try to use a soft disk: Put a floppy drive next to the computer you just edited and open a soft disk
Open the computer GUI, first use the Label Set Right Right FD01 to name FD01 for FD01 (because the soft disk driver in my example is Right on the right side of the computer, other devices can be filled with up and down keys). At this time, enter list or LSYou will find an extra DISK directory.
Enter the Copy Startup.lua Disk to copy the file into the soft disk, CD DISK enters the soft disk directory, and enter the list to view the directory.
After confirming that the file has been copied, you can take the floppy disk directly from the soft drive, put it in another soft drive next to the computer that is touched by the speed controller and the stress watch, and restart the computer.
This interface also shows that the software is successfully started.Ordinary computers do not support color display. There is no multi -window function. In this state, press the second button in the upper left corner to stop the current program before other operations can be performed.
If there is no corresponding device next to the computer, the computer will pop up an error similar to the following figure. At this time, the program cannot run