This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
component:hologram [2014/07/09 23:52] sangar created |
component:hologram [2017/11/05 07:19] (current) breadbolt |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | This component is provided by the Hologram Projector. | + | Component: Hologram |
- | 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. Tier two holograms do not provide a higher resolution, instead they allow using up to three colors in the displayed hologram (as opposed to just one for the tier one hologram). | + | ================== |
+ | This component is provided by the [[block:hologram_projector|Hologram Projector]]. | ||
+ | These can be used to create holographic projections in a resolution of 48x32x48, over a maximum area of 9x6x9 blocks. Tier two holograms do not provide a higher resolution, instead they allow using up to three colors in the displayed hologram (as opposed to just one for the tier one hologram). | ||
Component name: `hologram`. | Component name: `hologram`. | ||
Line 9: | Line 11: | ||
- `get(x:number, y:number, z:number):number` | - `get(x:number, y:number, z:number):number` | ||
Returns the value at the specified position. | Returns the value at the specified position. | ||
- | - `set(x:number, y:number, z:number, value:number)` | + | - `set(x:number, y:number, z:number, value:number or boolean)` |
Set the value for the specified position. | Set the value for the specified position. | ||
- | - `fill(x:number, z:number, height:number, value:number)` | + | - `fill(x:number, z:number[, minY:number], maxY:number, value:number)` |
- | Fills a column to the specified height with the specified value. All voxels below and including the specified height will be set, all voxels above will be unset. | + | Fills an interval in the specified column column with the specified value. Will overwrite only the voxels in the interval. If `minY` is omitted it defaults to 1. The two interval ends are inclusive. |
+ | //Note:// Before 1.3.3 there was no `minY` argument and all voxels below and including the specified height would be set, all voxels above would be unset. | ||
- `copy(x:number, z:number, sx:number, sz:number, tx:number, tz:number)` | - `copy(x:number, z:number, sx:number, sz:number, tx:number, tz:number)` | ||
Copies an area of columns by the specified translation. | Copies an area of columns by the specified translation. | ||
Line 19: | Line 22: | ||
- `setScale(value:number)` | - `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. | 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. | ||
+ | - `getTranslation:number, number, number` | ||
+ | Return the current translation offset. | ||
+ | - `setTranslation(x:number, y:number, z:number)` | ||
+ | Set the translation vector. The hologram display will be offset by this vector from its normal location. The maximum allowable translation is a function of tier. Units are the hologram's size, so the distance translated increases and decreases with scale as well. | ||
- `maxDepth():number` | - `maxDepth():number` | ||
The color depth supported by the hologram. | The color depth supported by the hologram. | ||
- `getPaletteColor(index:number):number` | - `getPaletteColor(index:number):number` | ||
- | Get the color defined for the specified value. | + | Get the hex color defined for the specified value. |
- `setPaletteColor(index:number, value:number):number` | - `setPaletteColor(index:number, value:number):number` | ||
- | Set the color defined for the specified value. | + | Set the hex color defined for the specified value. |
Simple example program that allows setting individual voxels: | Simple example program that allows setting individual voxels: | ||
Line 30: | Line 37: | ||
local component = require("component") | local component = require("component") | ||
local hologram = component.hologram | 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 = {...} | local args = {...} | ||
- | setVoxel(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4] == "true" or args[4] == "on") | + | hologram.set(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4] == "true" or args[4] == "on") |
``` | ``` | ||
Line 50: | Line 45: | ||
Further examples: | Further examples: | ||
+ | |||
- [Holo Flow](https://github.com/OpenPrograms/Sangar-Programs/blob/master/holo-flow.lua) | - [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. | This program generates a heightmap and 'moves' across it over time, creating the effect of a flowing terrain. | ||
Line 55: | Line 51: | ||
This program generates a random heightmap and displays scrolling text above it. | 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`](https://github.com/OpenPrograms/Sangar-Programs/blob/master/noise.lua) script to be in the same folder. | + | Note, the second example is quite a bit more advanced then the first. **Important**: both scripts also need the [noise.lua](https://github.com/OpenPrograms/Sangar-Programs/blob/master/noise.lua) script to be in the same folder. |
---- | ---- | ||
{{page>component:contents&noheader&noeditbutton&nouser&nofooter}} | {{page>component:contents&noheader&noeditbutton&nouser&nofooter}} |