Basics of scripting: Difference between revisions

From Fancade Wiki
m (Text replacement - "Category:Scripts" to "Category:Scripting")
(link to Object)
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
Line 19: Line 19:
* <b><font color="ff8543">Orange</font></b> is a [[rotation]]
* <b><font color="ff8543">Orange</font></b> is a [[rotation]]
* <b><font color="ff4343">Red</font></b> is a [[Truth]], it is either <code>True</code> or <code>False</code>
* <b><font color="ff4343">Red</font></b> is a [[Truth]], it is either <code>True</code> or <code>False</code>
* <b><font color="ff85c8">Pink</font></b> is an object
* <b><font color="ff85c8">Pink</font></b> is an [[object]]
* <b><font color="a7b1d0">Gray</font></b> is a [[constraint]]
* <b><font color="a7b1d0">Gray</font></b> is a [[constraint]]
* <b><font color="ffe043">Yellow</font></b> is for execution control
* <b><font color="ffe043">Yellow</font></b> is for execution control

Latest revision as of 14:30, 23 August 2025

Some blocks have wires sticking out of them. These are script blocks and you script by connecting their wires to other script blocks.

When you tap Play, script blocks execute (activate) and do their thing. E.g. Set Score sets the current score, so if we wire the Number 3 to it, the score is set to 3.

Basics set score.png

Blocks execute top-to-bottom, left-to-right. But you can plug in the yellow control wires to change the execution order. This is especially useful when you want to execute a block only some of the time.

(see Execution order for more details)

For example, here I've wired a Touch Sensor to Win, so when the player taps, then the game is won:

Basics tap to win.png

There are other wire colors as well:

That's the basics! Now, you'll probably learn a lot more by looking at some example scripts that show how to do useful game stuff. So start Fancade and look on the Build tab to find a game called "Tutorial". It's fully editable, so you'll be able to see and play around with each example script.