Camera Module
Добавить в игру через Steam
Нажмите «Подписаться»
На странице Steam войдите в аккаунт, если потребуется.
Подписаться
О материале
«Camera Module» — материал мастерской Scrap Mechanic. Постройки, новые блоки, детали и игровые режимы. Данные Steam, описание автора и ссылка для установки через подписку. Совместимость редакцией не проверена.
Описание автора
This mod adds a camera to the game that can be used to take images to analyse them :) Note: Place the camera with the round end of the AND symbol facing upwards
SMPL API
getCameras
parameters: []
description:
returns all cameras connected to the computer
setResolution
parameters: [camera, width, height]
description:
sets the resolution that the camera renders
setFov
parameters: [camera, width, height]
description:
sets the fov of the camera
setMode
parameters: [camera, mode]
description:
sets the mode of the camera
Camera.DISTANCE
Camera.COLOR
Camera.TYPE
setCastsPerTick
parameters: [camera, amount]
description:
sets how many raycasts a camera performs per tick
setRange
parameters: [camera, range]
description:
sets the number of units the raycast goes
capture
parameters: [camera]
description:
starts the capturing process
isCapturing
parameters: [camera]
description:
returns if the camera is currently rendering
getData
parameters: [camera, x, y]
description:
returns the data for a specific pixel. depending on the mode...
DISTANCE -> Number
TYPE -> String
COLOR -> Tupel
(
r: Number,
g: Number,
b: Number
)
ALL -> Tuple
(
hit: Boolean,
distance: Number,
type: String,
color: Tuple
(
r: Number,
g: Number,
b: Number
)
)
getResolution
parameters: [camera]
description:
returns the resolution of the camera as a tuple (width, height)
Example
This is a simple example that uses the camera and the screen. This is what the program is doing (in general) 1. setting up the screen 2. setting up the camera 3. capturing an image 4. render the image to the screen
import Screen
import Camera
import Math
II.setClockSpeed(10000)
screen = Screen.getScreens()[0]
(screenWidth, screenHeight) = screen.getResolution()
screen.setSize(96, 54)
print('clearing screen')
screen.fillRect(0, 0, screenWidth, screenHeight, (0, 0, 0))
range = 100
camera = Camera.getCameras()[0]
camera.setCastsPerTick(400)
camera.setResolution(90, 50)
camera.setFov(120, 90)
camera.setRange(range)
camera.setMode('ALL')
camera.capture()
print('capturing image')
while camera.isCapturing()
II.interrupt()
end
print('drawing image')
(width, height) = camera.getResolution()
print(width, height)
for y = 1, y <= height, y += 1
for x = 1, x <= width, x += 1
entry = camera.getData(x, y)
if entry[2] == 'harvestable'
screen.fillRect(x, y, 1, 1, entry[3])
elseif entry[0]
v = 1.0 - entry[1] / range
screen.fillRect(x, y, 1, 1, (v, v, v))
else
screen.fillRect(x, y, 1, 1, (0, 0, 0))
end
end
end
Как установить и запустить
Откройте оригинальную страницу в Steam Workshop, проверьте версию игры, зависимости и порядок загрузки в описании автора. Нажмите «Подписаться» и дождитесь загрузки Steam. Включите материал в меню модификаций или контента игры, если это требуется. Совместимость и запуск редакцией не проверены.