Skip to main content

Hacking an entity

In SCS, hacking allows you to change the behaviour of entities in the game most entities in SCS are hackable.

How to hack

To hack an entity, select the entity in the World Editor and tap the HACK button from the selection menu. If there is no HACK button, then the entity is not hackable!

Hack Button

Tapping the HACK button will open the Lua Editor.

Lua Editor

Every hackable entity in SCS is controlled by a script written in Lua these scripts can be modified using the Lua Editor.

Lua Editor

Above is a screenshot of the Lua Editor, with the following key elements highlighted:

  1. MENU toggles the Script Explorer.
  2. SCRIPT NAME displays the name of the active script. Tap to change the name of the script.
  3. SEARCH toggles the search panel.
  4. UNDO undoes recent changes.
  5. REDO restores recently undone changes.
  6. SAVE saves the active script and closes the editor.

Tapping on the MENU button will open/close the Script Explorer, which contains a list of all the scripts available in the world.

Script Explorer

Above is a screenshot of the Script Explorer, with the following key buttons highlighted:

  1. DELETE deletes the active script.
  2. CREATE creates a new script.
  3. CLONE clones the active script.
  4. ACTIVE highlights the active script. To assign another script to the entity, simply select it in the Script Explorer.

Hacking the arrow

Let's hack something! Select the arrow and tap the HACK button to open the Lua Editor.

Hack Arrow

When the editor opens, you should see the following default Lua code. If you do not see this code, make sure you're hacking the arrow, and check the Script Explorer (see the section above) to make sure the active script is "Arrow (Read-Only)".

Arrow Default Script

Tap on the pink bar to edit the "Read-Only" default code. Then tap on the script name to change it to something relevant (i.e. "Arrow1".)

Arrow Script Name

Now, edit the script so that it does what you want it to do. In this case, we will change the text that appears above the arrow to "Level 1" instead of the default string, "Go that way".

Arrow script
function onStart()
-- Text that appears above the arrow
Speech.setText("Level 1")
end

Let's go through what each line of the script does.

function onStart()

This declares the onStart function, that will be called when the program starts running.

-- Text that appears above the arrow

This is a comment in Lua, a comment is text that is ignored by the Lua interpreter. Comments are generally used to make code more understandable, often by explaining the intent of code by the programmer who wrote the code.

Speech.setText("Level 1")

This calls the setText() function from the speech module. The argument inside the () is the string that will show in the game.

end

This closes the onStart() function.

Now, press the SAVE button (green button on the top-right of the Lua Editor).

Testing your world

To see your code run, enter "test mode" by pressing the TEST button in the World Editor you should see the text "Level 1" appear above the arrow instead of the default "Go that way" text.

Arrow Script Test