SComputers - Api Reference
SComputers, this is a fork of the ScriptableComputer mod
this fork is compatible with the code of the original ScriptableComputer
however, programs written for this mod will not work on the original ScriptableComputer
in the original "ScriptableComputer" luaInLua worked terribly and contained a bunch of bugs.
SComputers uses a FiOne_lua virtual machine that runs about 5 times faster
and it does not contain any bugs except for the lack of "goto" support.
now the number of iterations is unlimited, but the execution time of one tick is limited, if the computer does not have time to execute the code in time, an error will pop up
you can configure how much the computer can "delay" the game-tick in the "Permission Tool" (by default: 4 ticks)
if you install the betterAPI dll mod, SComputers will use native lua, which will significantly increase performance.
SComputers has a lag-score mechanic that prevents lags from being called
if the computer runs the code for a long time (it takes a lot of processor time) then he is credited with a lag-score, which can lead to missing clock cycles. which actually means that you won't get control for the next tick of the game
documentation sections:
warnings
- exceptions in callback_error, onError, clientInvoke, clientInvokeTo cannot be handled in any way other than viewing game logs/debug console
- on a computer with an embedded disk, it will always be defined as the first disk, and the connected external disk will always be the second
recommendations
- it is recommended to install a dll mod: betterAPI this will increase the mod's performance and add new functionality
- if the antenna on your device works only for receiving then you can put an NFC antenna, the antenna radius affects only the transmission
- it is not necessary to update the display every clock cycle, often it does not make sense. in most cases, updating 4 times per second will be enough, for this it is enough to insert "if getTick() % 4 == 0 then --[[display update code]] end" at your program
small changes
- in safe-mode, additional checks have been added to some methods of the SM library (in order to avoid crashes)
- when using clientInvoke(available only in unsafe-mode), ENV will be saved, however, the code is loaded anew every time
- clientInvoke(str, ...) supports arguments
- exceptions "path .. underflow" cannot be retrieved. the extra ".." is simply ignored
- the combination of characters "\n" (two separate characters and not a new line) can be displayed in the gui as "¦n" this is due to the fact that mygui (which uses scrapmechanic) turns "\n" into a new line (at the same time, "¦n" works like normal "\n")
- now, when disabling a component/removing a component, it is guaranteed not to be work
- now the stepper motors do not create any force in the off state
- now the camera is able to see the units in a separate (by you exposed) color(by default, this color is bright white in all rendering modes)
- the camera's FOV is limited to 165 degrees
- the radar.getTargets method can now be used only once per tick on one radar (to avoid noise filtering) if you need to filter the noise then use multiple radars
- port.nextPacket can now be called even if there are no packets in the buffer without the risk of an error, the method will simply return nil if the packet is not in the buffer
- port.nextPacket now it returns 2 values, the first is the packet itself, and the second is the ID of the port from which the packet was sent
- fixed a bug that prevented radars from seeing static objects
- print/alert/debug functions can be disabled in the Permission Tool
- when the computer crashes, it displays an error message on all connected monitors and terminals (if you want to turn this off then create a _disableBsod variable)
features
-
the crashstate table has been added to the public api of the computer (getChildComputers and getParentComputers and getCurrentComputer)
there are two values hasException and exceptionMsg
ATTENTION, the "crashstate" table in the public API is a shadow of the real "crashstate" table. as a result, you can read from it, but writing to it will not lead to any result
- components such as the keyboard, terminal and reboot gate can be connected to the seat
how to use the importer
- to generate an disk-image, use the importer utility, it is located in $CONTENT_DATA/USER/importer
- to import an disk-image, use the disk menu, to do this, press the E button on it
- to open this menu on a PC with a built-in disk, use the button in its gui
- when importing, old files are not erased, in order to erase them, click clear
- you can import your generated disk-image($CONTENT_DATA/USER/importer/disk.json), or a ready-made OS (scriptableOS)
- at the moment, importing/exporting a custom disk-image only works when you are the host!
- the "import from importer" and "export to importer" buttons import and export the disk-image to the importer file(disk.json) the buttons below are responsible for importing/exporting to the "$CONTENT_DATA/USER/userdisks" folder
- on "windows", it is usually located along the path: "C:\Program Files (x86)\Steam\steamapps\workshop\content\387990\2949350596\USER\importer"
why do the disks in SComputers have such a small volume
disk sizes are GREATLY reduced in order to avoid non-spawning creations and saving bugs.
the game cannot save even megabytes of data to blueprint(max blueprint size 512kb).
now small and embedded disks have a volume of 64kb, a larger 128kb.
creative hard drive has a volume of 1024 MB, but does not save data after re-entry and when saving.
if you need to save large amounts of data to a disk, then you can use the "world disks" addon.
if you need to distribute a large amount of data along with your creation in the workshop, you can use "ROM disk"