Author Topic: Three new types of variables  (Read 1172 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
Three new types of variables
« on: December 28, 2018, 03:10:13 PM »
3 new variable types
There still many things that PB has to improve in. These three variables may seem very complex but they can be useful while creating our games:

Local Variables · String Variables · Object Variables

Local Variables
Local Variables are unique for each command prompt and return it's value to 0 when the command prompt ends. The point for this variable is that the same name for a local variable running at the same time on different command prompts will work well and can have different values each other at the same time :/

String Variables
This may be the most complex variables but probably required. String Variables are variables that can't operate. (Example: You can't do string variable + 1) and can contain letters and numbers
Example of use:
Code: [Select]
<string variable player_name>Antikore
<npc 1>Hello, [string variable player_name]. Welcome to your new house!

This will return an NPC talking "Hello, Antikore. Welcome to your new house"
String variables also will require some new commands and conditionals like:
Length of (String variable)
Code: [Select]
if length of string variable player_name > 16 | length of string variable player_name < 4
{
<player 1>Your name should contain between 4 and 16 characters
}
Also to check what is the content:
Code: [Select]
if <string variable password>VivaVegetta777
{
<npc 1>You can continue [string variable player_name].
}
Other suggestion for working with string variables
  • "Letter X of (String variable)" conditional
  • "(String variable) contains letter X" conditional
  • A textbox to write in while in game
  • "(String variable) is empty" conditional
  • "Downcase/Uppercase (String variable)" command

Object Variables
This can be in 2 ways:
  • Object string variable
  • Object variable

Object variables act as the local variables but will not return at 0 when a command prompt is finished and will be unique for each object. For example, There are two custom gruppies, when you damage one, the next command prompt is executed
Code: [Select]
if percent chance = 50
{
object variable anger + 1
}
if object variable anger = 3
{
enemy = enemy 15
}
This variable is only detected by the gruppy we have damaged. With object variables, the first gruppy can have anger = 2 and the other can have anger = 1 simultaneously.

Thank you for reading


Sorry because my English is not very good because I'm Spanish ;) :P

CGM

  • Christian, 3D artist, former Platform Builder gamdev
  • Master Builder
  • *
  • Posts: 3836
    • View Profile
Re: Three new types of variables
« Reply #1 on: December 29, 2018, 02:19:41 AM »
Interesting... A bit over my head, but okay.