Yes coding is hard but we will cover every single piece of code there is in Castle
If you are looking for how to make assets or types of games on Castle, check out my channel! It has tutorials on how to make a clicker game or, how to make a ball spawn. If that's what you need, click the funny ball below:
If you don't have a clue what Castle is, here are some links to help you:
Or you can just go to the Castle Discord by pressing the tiny Discord button (If you can find it) Also you need to download Discord on your phone so you can get into the Castle Discord
Debatably most important part
Before we get into coding, the deck variable we will be using for examples shall be $var, our actor variable will be $var_a.
Please note there is a difference, we will get into it eventually.
This is likely the actual most important trigger if you are focusing on animations or cutscenes
How it works:
Using this trigger will run code below it when the card has loaded
This is most important for creating buttons or chain reactions,
How to use this:
This one is a bit complex, just assign an actor that you want the actor with this code to a tag example. #obj . Now set the code tag to the tag #obj. When the actor collides with #obj the code below will run.
This one is just like "When this is created" but except for when its deleted.
How it works:
Whenever the code "Destroy this actor" runs, this will be triggered causing the code below it to run.
This is a very useful piece of code in many ways.
How to use:
Whenever the actor is tapped/clicked on, the code below it runs.
This trigger is special. Not just cause it's the only trigger that says "while" instead of "when.". It's because it plays a special role in goofing around with items & clickers.
How to use:
This works like "When this is pressed" but instead the code runs every 0.0167 seconds. (That is if your finger is still on the actor.).
This works like "When tapped" but runs the code immediately once touch is detected between your finger and the screen.
This works like "When tapped" but it waits for the contact between your phone and your finger to stop. Then it runs the code.
This is normally used in a template, and I don't know why.
How to use.
Whenever the actor gains a specific tag, for example, let's use #obj again. Say that an actor with #block collides with the actor that we are mainly focusing on, and this actor we are focusing on has a code that goes like this:
"When this collides with an actor with tag #block
Add tags to this actor (Add tags): #obj"
When the actor gains tag # obj, the code below it will run.
Alternates:
We could use Modify $var & if $var but. we could get on with that later.
This is kind of just like "When this gains a tag" so I copy and pasted everything and modified some.
How to use.
Whenever the actor loses a specific tag, for example, let's use #obj again. Say that an actor with #block collides with the actor that we are mainly focusing on, and this actor we are focusing on has a code that goes like this:
"When this collides with an actor with tag #block
Remove tags to this actor (Remove tags): #obj"
When the actor loses tag # obj, the code below it will run.
Alternates:
We could use Modify $var & if $var but. we could get on with that later.
"When a variable changes" is not to be confused with "When a variable reaches a value"
When a variable changes is run whenever a specific variable changes from its previous value.
How to use (Example):
(Actor 1 rules):
When this is created
Repeat every {1} seconds
Modify deck variable {$var} to {1}
Relative to current value [TRUE]
(Actor 2 rules):
When variable changes: {$var}
Create a text box {"The new number is $var"}, when tapped {none}
Wait for {1} {second}