• Starting today August 7th, 2024, in order to post in the Married Couples, Courting Couples, or Singles forums, you will not be allowed to post if you have your Marital status designated as private. Announcements will be made in the respective forums as well but please note that if yours is currently listed as Private, you will need to submit a ticket in the Support Area to have yours changed.

How To Set And Draw Variables?

Variables can be used for a lot of things. For example, stocks of items, lives, health, rpg stats, etc. They can be useful and easy to use. You may also used variables when the player touches an object or destroys an enemy.

Set Variable
There are many built-in variables in the game. With this action you can change these. Also you can create your own variables and assign values to them. You specify the name of the variable and the new value. When you check the Relative box, the value is added to the current value of the variable. Please note that this can only be done if the variable already has a value assigned to it! See below for more information about variables.

This d&d action is used to create your own variables and set values to them. To do this, you must first set the desired variable and the desired value to it in the create event of an object. After that, you then check the Relative box to add the value to the current value of the assigned variable.


Draw Variable
With this action you can draw the value of a variable at a particular position on the screen. Note that this can only be used in the draw event of an object.


This d&d action is used to draw the value of a variable at a certain position on the screen. This action is only effective in the draw event of an object. You must also set the specific object of a draw variable referring to the specific object.

To do this in coding, you must do the same thing for creating variables using this code of a specific object you're referring. For example, obj_player.insertvariablename=value;

For global variables you used this code instead:
global.insertvariablename=value;

draw_text(x,y,"x" + string(obj_insertvariable_name));
The x is there to indicate the stocks of items, score, and lives in platform game elements.

draw_sprite(spr_insertitemname,0,x,y);
This is for drawing the variable of a specific variable to show the current value on the screen.

Blog entry information

Author
LinkxPeach
Read time
2 min read
Views
77
Last update

More entries in Old Blog Software

More entries from LinkxPeach

Share this entry