Updated Component Hologram (markdown)

Florian Nücke 2014-03-18 01:36:02 -07:00
parent 20b9a98635
commit 09f2b42bd0

@ -1,5 +1,5 @@
This component is provided by the Hologram Emitter.
These can be used to create holographic projections in a maximum area of 48x32x48.
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:
@ -10,15 +10,39 @@ Callbacks:
- `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.
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 render scale of the hologram.
Returns the current render scale of the hologram.
- `setScale(value:number)`
Set the render scale. A larger scale consumes more energy.
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.
Example usage(programs below created by Sangar):
[Holo Flow](https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-flow.lua) --Generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain.
Simple example program that allows setting individual voxels:
```lua
local component = require("component")
local hologram = component.hologram
[Holo Text](https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-text.lua) --Generates a random heightmap and displays scrolling text above it.
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](https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-flow.lua)
This program generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain.
- [Holo Text](https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-text.lua)
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.