Author Topic: Dynamic Variables: What are they and what are they for?  (Read 1908 times)

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Dynamic Variables: What are they and what are they for?
« on: May 18, 2020, 01:28:41 PM »
Hi! I'm Antikore and I want to show you something awesome for your games.
I named these things as "Dynamic Variables"

A dynamic variable is a variable that uses bracketings for the variable name. This is awesome to set different variables without needing to have multiple times the same code.

A good example is making an item that when collected sets a variable specific for the current area we are, with this we can make super mario 64-like star system.
Code: [Select]
//The star nº1 from the current area is collected, so is set to true
game var stars[area]_n1 = true
If we are on the area with id 25, the variable will set the variable stars25_n1 to true. We can check an specific variable by just replacing the bracketing with the possible returned value. For example, if we want to check for the star nº1 from the area 18, just change [area] to 18
Code: [Select]
if game var stars18_n1 = true
//What to execute if we have the star nº1 from the area 18

I have used this on my dungeon game with the character system.
The character select has a variable that refers to which character is selected by the player
Code: [Select]
var chara = 1 //Set the character selected to 1
Each time you use your arrow keys, you add or remove to this variable, and the character values change to the saved for that new character.
How?
Code: [Select]
//Example:
if game var ch[var chara]_level = 1
{
var level = 1
var price = 100
}

Hope you learned something new from this tutorial. Thanks for reading and see ya next time!
« Last Edit: May 18, 2020, 01:28:59 PM by Antikore »
Sorry because my English is not very good because I'm Spanish ;) :P

War

  • "The top player is here!"
  • Level 20: Nobom
  • *
  • Posts: 1490
    • View Profile
    • My website
Re: Dynamic Variables: What are they and what are they for?
« Reply #1 on: May 18, 2020, 03:43:41 PM »
A dynamic variable is a variable that uses bracketings for the variable name.
So yeah brackets make variables "dynamic"
Hey, wassup wassup? My name is Warrior555MainsGanon (but just call me War) and I'm the main guy behind Megaman Zero Online and the upcoming Matt's Adventure! I don't speak often here but I'm a very friendly lad so if you wanna talk, don't hesitate!

Antikore

  • Developing Mortal Theater at day, developing depression at night.
  • Level 22: Trex
  • *
  • Posts: 2020
  • Enjoying Platform Builder from the very start
    • View Profile
    • PBuilder Resources
Re: Dynamic Variables: What are they and what are they for?
« Reply #2 on: May 18, 2020, 03:49:07 PM »
So yeah brackets make variables "dynamic"
Brackets can be used on variable names to make them "dynamic"
Dynamic because with a variable with a bracketing the variable is not fixed.
I think dynamic is a good name
Sorry because my English is not very good because I'm Spanish ;) :P