Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
component:hologram [2014/07/09 23:52]
sangar created
component:hologram [2014/07/10 09:07]
vexatos
Line 1: Line 1:
 +Component: Hologram
 +==================
 This component is provided by the Hologram Projector.  ​ 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. 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). 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).
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, height:​number,​ value:​number)`  ​
Line 30: Line 32:
 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 55: Line 45:
   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}}