mozaic_tips_and_tricks

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
mozaic_tips_and_tricks [2020/01/12 21:09] – Added two and multi dimensional array acces _kimozaic_tips_and_tricks [2020/01/12 21:16] – [Store two positive Values into a single Variable] Fixed typo _ki
Line 3: Line 3:
 This wiki page contains programming tips & tricks for [[mozaic_plugin_engine|Mozaic]] This wiki page contains programming tips & tricks for [[mozaic_plugin_engine|Mozaic]]
  
 +
 +  * [[mozaic_tips_and_tricks#Two dimensional Arrays]]
 +  * [[mozaic_tips_and_tricks#Multi dimensional Arrays]]
 +  * [[mozaic_tips_and_tricks#Store two positive Values into a single Variable]]
   * [[mozaic_tips_and_tricks#Store three unsigned Bytes into a single Variable]]   * [[mozaic_tips_and_tricks#Store three unsigned Bytes into a single Variable]]
   * [[mozaic_tips_and_tricks#Some Best Practice Tips]]   * [[mozaic_tips_and_tricks#Some Best Practice Tips]]
Line 48: Line 52:
  
 \\  \\ 
- 
  
 ===== Multi dimensional Arrays ===== ===== Multi dimensional Arrays =====
Line 61: Line 64:
 \\  \\ 
  
-===== Store two positive values into a single Variable =====+===== Store two positive Values into a single Variable =====
 <html><p align = "right"><small><i>From -ki</i></small></p></html> <html><p align = "right"><small><i>From -ki</i></small></p></html>
 It is possible to store two positive values in a single variable if their product is less than 16.777.216 It is possible to store two positive values in a single variable if their product is less than 16.777.216
Line 67: Line 70:
  
 <code> <code>
-  offset = 1000  // Maximum value for B plus one +  maxB = 1000  // Maximum value for B plus one 
-  valA   = 723   // allowed range 0 .. ~16000 +  valA = 723   // allowed range 0 .. ~16000 
-  varB   = 124   // allowed range 0 .. 999+  varB = 124   // allowed range 0 .. 999
      
-  combinedValue = valA * offset + valB+  combinedValue = valA * maxB + valB
 </code>  </code> 
  
 To later extract the values from their packed format use To later extract the values from their packed format use
 <code> <code>
-  valA = RoundDown combinedValue / offset +  valA = RoundDown combinedValue / maxB 
-  valB = combinedValue % offset+  valB = combinedValue % maxB
 </code> </code>
 \\  \\ 
  • mozaic_tips_and_tricks.txt
  • Last modified: 2024/04/23 19:07
  • by _ki