Simple Scripts

This section will help explain how to create simple scripts for commonly posted scripting problems.


Walk to Cursor Location

Edit the “Left Click (Pressed)” Control Combination (the one with the blue downward arrow) inside the “Cursor” Input Set of the Input Triggers window. Underneath the “Cursor Action Down” event, simply create a “Walk to Cursor” event. The player will now move to wherever the cursor is clicking on the Map.

Alternatively, you can use a “Walk To Location” event instead. Select “(Main)” for the Map (so that it’s always looking at where the player is currently located) and use Cursor.TargetXofZ(0) and Cursor.TargetYofZ(0) for the X and Y coordinates respectively.

Game Recipe #7 - Custom Cursor

In this recipe, we’ll go over how to set up a custom cursor. We’ll be switching to the custom cursor upon starting or loading a game, but you can use the same event to change the cursor between sprites in the middle of the game, if you’d like.


Flashlight/Torch

Create a Light on a Map of your choosing. Then create a Timer with “Every Interval” set to a small value like 0.025 seconds. Then inside the “Every timer tick” trigger, use a “Position Light” event to move the Light to the player’s X and Y coordinates: Actor(“main”).X and Actor(“main”).Y

For an added layer of depth, you may wish to create a battery Variable that slowly depletes as the light is in use and re-charges when the light is turned off.

Game Recipe #1 - Simple Following Flashlight/Torch

In this Game Recipe, we will be going over how to make a light follow an actor. We will be covering how to make a light that is centered on a player, or a light that is positioned in front of the player.


RPG – Flashlight (Bonus 1/2)

In the first part of this bonus tutorial we’ll be learning how to create a flashlight as well as making a roof for our bedroom that toggles on/off when the player enters/leaves.


Day/Night Cycle

First create a Switch to toggle between daytime and night-time – ensuring the “Default Value” is set to “ON”. Next, create a Timer on your “HUD” Interface with “Every Interval” set to a large value like 5 minutes. Then inside the “Every timer tick” trigger, use a “Switch Branch” event to check the state of your day/night cycle. Use a “Change Sun Color” event, with a light color for when the Switch is turned ON and a darker color for when the Switch is turned OFF. For best results, ensure your “Change Sun Color” events have a fairly lengthy duration (eg: 30 seconds) so that the transition from day to night is not instantaneous.

For a more advanced day/night cycle, you may wish to use the “Date / Time” Use Values to retrieve the actual date/time from the user’s machine and set up a day/night cycle accordingly. You may also want your Shops/Inns to be affected by the current day/night cycle by having them open/close during the day/night respectively.


Dice Roll/Fishing System

Inside an appropriate trigger, create a “Random Probabilities Branch” event and set at least two different probabilities out of 100% (eg: “Probability 1” = 50%, “Probability 2” = 35% and “Probability 3” = 15%). For each probability, a new node will be created to set up appropriate rewards for each outcome. For the highest probabilities (the ones it’s most likely to land on) assign common/low value rewards and for the lowest probabilities (the ones it’s least likely to land on) assign rare/high value rewards.