Share
 
 

About 3S Scripts

With 3S scripts you define functions for later use in Selective Space Structures to be performed when a structure is applied to a part, or on a case-by-case basis.

Lua in 3S

The programming language is based on the Lua script language. Refer to the official manual for more information about the Lua script language (www.lua.org/manual/5.0). The scripting reference for 3S is part of the Netfabb Lua API reference.

Lua cheat sheet

Lua objects

Methods are accessed with a colon.

object:method(...);

Properties are accessed with period.

object.property;
Variables
Values are assigned to variable with a single equals sign.
Variable = Value
This defines and initializes the variable. For many operations, you can choose any name as variable and assign elements of 3S to that name. For example:
cell=structure:findcell("cell1");

In this example, the cell with the name cell1 in the 3S Generator is from now on referred to as cell in the script. For some methods, you can add the Boolean value true or false.

Relational operators
  • == Equal
  • ~= Not Equal
  • < Less Than
  • <= Less Than or Equal
  • > Greater Than
  • >= Greater Than or Equal
Arithmetic operators
  • +, -, *, /, % Basic arithmetic operations
  • ^ Exponent
  • and, or, not Boolean operations
Conditional branching
  • if condition then block end
  • if condition then block1 else block2 end
  • if condition then block1 elseif condition2 then block2 else block3 end
  • for variable = start, end, jump distance do block end
  • while condition do block end
  • repeat block until condition
  • break to abort or finish the current loop immediately

Was this information helpful?