SCRIPTING your own part!

Опубликовано: 05 Август 2026
на канале: Brent Batch
5,815
110

This Scrap Mechanic tutorial covers: creating a basic scripted part with scripted input/output using a custom display! (UvFrameIndex)
(template lua code at the end of this description!)

Usefull links:
Scrap lua api: http://scrapmechanic.com/api/index.html
Learning lua syntax: https://www.lua.org/manual/5.1/manual...
Uuid4 generator: https://www.uuidgenerator.net/
Json validator: https://jsonlint.com/
Online lua tester: https://rextester.com/l/lua_online_co...


discord:   / discord  


👥🗣Channel-links:
🔔http://www.youtube.com/c/brentbatch?s... 🔔
turn notifications on to never mis out on anything! :D


[email protected]
👥  / brentbatchyt👥  
Steam group: http://steamcommunity.com/groups/Bren...


template lua code:

GenericClass = class( nil )
GenericClass.maxChildCount = -1
GenericClass.maxParentCount = 1
GenericClass.connectionInput = sm.interactable.connectionType.logic
GenericClass.connectionOutput = sm.interactable.connectionType.logic -- none, logic, power, bearing, seated, piston, any
GenericClass.colorNormal = sm.color.new(0xdf7000ff)
GenericClass.colorHighlight = sm.color.new(0xef8010ff)
--GenericClass.poseWeightCount = 1


--[[ client ]]
function GenericClass.client_onCreate( self )
end
function GenericClass.client_onRefresh( self )
self:client_onCreate()
end

function GenericClass.client_onSetupGui( self )
end

function GenericClass.client_onFixedUpdate( self, deltaTime )

end

function GenericClass.client_onUpdate( self, deltaTime )
end

function GenericClass.client_onDestroy( self )
end
function GenericClass.client_onInteract(self)
end
function GenericClass.client_canInteract(self)
end
function GenericClass.client_onProjectile( self, position, time, velocity, type )
end

--[[ server ]]
function GenericClass.server_onCreate( self )
end
function GenericClass.server_onRefresh( self )
self:server_onCreate()
end

function GenericClass.server_onFixedUpdate( self, deltaTime )

end

function GenericClass.server_onDestroy( self )
end
function GenericClass.server_onProjectile( self, position, time, velocity, type )
end
function GenericClass.server_onSledgehammer( self, position, player )
end
function GenericClass.server_onExplosion( self, position, destructionLevel )
end
function GenericClass.server_onCollision( self, other, position, velocity, otherVelocity, normal )
end