-
Notifications
You must be signed in to change notification settings - Fork 435
Component Hologram
For those that don't like images: the wiki has moved to a new place, http://ocdoc.cil.li/.
This wiki will no longer be updated.
This component is provided by the Hologram Projector.
These can be used to create holographic projections in a resolution of 48x32x48, over a maximum area of 9x6x9 blocks. Holograms are defined via 48x48 32-bit bit masks, where each bit defines whether the voxel at that height should be on or off.
Component name: hologram
.
Callbacks:
-
clear()
Clears the hologram. -
get(x:number, z:number):number
Returns the bit mask representing the specified column. -
set(x:number, z:number, value:number)
Set the bit mask for the specified column. -
fill(x:number, z:number, height:number)
Fills a column to the specified height. All voxels below and including the specified height will be set, all voxels above will be unset. -
getScale():number
Returns the current render scale of the hologram. -
setScale(value:number)
Set the render scale. A larger scale consumes more energy. The minimum scale is 0.33, where the hologram will fit in a single block space, the maximum scale is 3, where the hologram will take up a 9x6x9 block space.
Simple example program that allows setting individual voxels:
local component = require("component")
local hologram = component.hologram
function setVoxel(x, y, z, value)
local current = hologram.get(x, z)
local positiveMask = bit32.lshift(1, y - 1)
if value then
hologram.set(x, z, bit32.bor(current, positiveMask))
else
local negativeMask = bit32.bnot(positiveMask)
hologram.set(x, z, bit32.band(current, negativeMask))
end
end
local args = {...}
setVoxel(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4] == "true" or args[4] == "on")
Example use (assuming it's saved as holo-set.lua
):
# holo-set 16 8 20 true
Further examples:
-
Holo Flow
This program generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain. -
Holo Text
This program generates a random heightmap and displays scrolling text above it.
Note, the second example is quite a bit more advanced then the first. Important: both scripts also need the noise.lua
script to be in the same folder.