Skip to main content

The .

The . is an operator that gives access to data contained within a table. The data contained within a table can be a variable or a function (these are often referred to as the “properties” of the table.)

The following program uses the PostProcess module to skew the color of the game to make it look like night time.

function changeBackground(player)
PostProcess.setColorAdjustments(player.id, 0, {180,180,180}, nil, -100)
end

function onSensorEnter(object)
if object.isPlayer == true then
changeBackground(object)
end
end

When the above program runs:

  1. The global event function onSensorEnter() is called by SCS whenever an object enters the sensor, and is passed the variable object (which is the object that entered the sensor).
  2. When onSensorEnter() is called, it calls the changeBackground() function, passing the variable object to it.
  3. When the changeBackground() function runs, it is passed the variable object, which is then assigned to the variable player.
  4. The changeBackground() function then the passes the id property from the player variable (i.e. player.id ) as an input to call the PostProcess.setColorAdjustments() function.