scmframework

SComputers Mod Framework



scmframework is a framework that allows you to make your mods based on SComputers and with SComputers functionality!
something like busybox for Scrap Mechanic
the framework is compiled using a special script from the SComputers scripts folder. the output is a single file
the scmframework build script comes with the mod and you can find it in the directory: USER/documentation/scmframework
the build script is designed for the windows operating system and runs through luajit
as the first argument, the script takes the path to the SComputers Scripts folder
the scmframework is a single file, your shape script can be either separate or inserted at the end of this file
the scmframework contains almost all SComputers, but without 3D models and textures
it also does not contain fonts converted from windows fonts, as they weighed too much
please note that although the framework itself is single-file, in order to use such things as displays, holographic projectors, GUIs, and standard samples in the synthesizer, you need to download additional files for scmframework
if you want to use a touchscreen, then most likely you will have to use the original display models from SComputers, you can download them and embed them in your mod
if you use scmframework in your mod, then leave a message about it in the description with a link to this page


scmframework demo


this mod demonstrates the capabilities of scmframework
the scmframework allows you to use SComputers features inside your mods
it's completely free and anyone can use the scmframework to create their own mods
if you only need displays from SComputers, then you can use canvasAPI
the scmframework contains canvasAPI inside itself

type: a mod based on scmframework


scmframework api


scmframeworkClass callbacks


scmframeworkClass methods


virtualShape methods


virtual computer methods


                dofile("$CONTENT_DATA/Scripts/scmframework.lua")
scmtest = class(scmframework.scmframeworkClass)

function scmtest:scmframework_init()
    --although the code is declared as constant here, it is not constant and can be changed via "setCode" inside the program. just like it happens in regular SComputers
    self.computer = self:addVirtualComputer([[local colors = require("colors")
local display = getComponent("display")
local synthesizer = getComponent("synthesizer")

function onStart()
    synthesizer.stopLoops()
    synthesizer.startLoop(1, "chapter2_alarm", {alarm = 2})
end

function onTick()
    local width = display.getWidth()
    local height = display.getHeight()

    for x = 0, width - 1 do
        display.fillRect(x, 0, 1, height, colors.combineColorToNumber(x / (width - 1), colors.pack(colors.hsvToRgb256(255 - (getUptime() % 256), 255, 255)), colors.pack(colors.hsvToRgb256(getUptime() % 256, 255, 255))))
    end

    display.flush()
end

function onStop()
    display.clear()
    display.flush()

    synthesizer.stopLoops()
end

_enableCallbacks = true]], nil, true)

    self.display = self:addVirtualDisplay(128, 64, 1, 1.2)
    self.computer:createVirtualLink(self.display)

    self.synthesizer = self:addVirtualSynthesizer()
    self.computer:createVirtualLink(self.synthesizer)
end

--[[
--you can allow the user to open the computer code if you uncomment this:
function scmtest:client_onInteract(character, state)
    self.computer:interact(character, state)
end
]]