Camera Module
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 (screenWidth, screenHeight) 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) ) elseif entry[0 v / range screen.fillRect(x, y, 1, 1, (v, v, v)) else screen.fillRect(x, y, 1, 1, (0, 0, 0)) end end end
Comments
0 total- No comments yet. Be first.
