Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Variable used as a boolean value

Author
Message
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 23rd May 2008 01:03 Edited at: 23rd May 2008 04:15
One thing that programmers like to have are variable switches that have a boolean value. The value 0 = false and the value 1 = true. This unleashes some real power for you as a programmer/game developer.

Need an example? Assign Global variable #0-99 (or Local Variable depending on the need) to a particular entity that the player needs to have in his inventory for later use. Set it with the initial value of 0 (false). When the player picks up this variable assign the variable 1 (true). Later you can see if the player had picked up this object by seeing if the variable is equal to 1 (or true). If it equals false (0) then the player cannot use this object. If it is true (1), then he can use it.

Any other uses you can think of?

** We are not Alone **
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd May 2008 11:13
Well, booleans are mainly used as flags for if something has been activated or set.

Witht hat in mind, you can pretty much think of anything in a game that could be considered as an "On/Off" or "Yes/No" answer to a question.

Question examples:

Did the player find the secret room in level 4?

Did the player happen to flip a switch a few levels back to activate a shortcut on this level?

Is the player's current super power turned On or Off?


Well, that's just a few off the top of my head. I'm willing to bet that other people can think of tons of things now.


The one and only,


Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 25th May 2008 02:21 Edited at: 25th May 2008 02:47
Quote: "Is the player's current super power turned On or Off?"

I prefer to use a larger scope of the variable instead of just 2 values.

So instead of using 0 and 1 for No or Yes to having Body Armor, I'd rather use a value for the body armor.

By using 0 through say 50, I can not only know if they have it but I also know how much.
That way I can decrement it with each shot taken so it will wear out instead of being infinite.
This also gives me a value to add back to the player's health after taking off for the shot.
So if each shot takes 50 health, then by adding back the value of the body armor we can take more damage as the armor wears out.

Sometimes booleans are neccessary for simple Yes/No or On/Off, but I avoid them if possible in the hopes of making something more dynamic.
With a preset number of variables available it becomes neccessary to get the most out of each one.

Another idea is to use one variable for multiple boolean values by using each digit as an On/Off or True/False.
So, a six digit variable value can be six different booleans.
This is less used because it is more complex but it is still an option nonetheless.
Now that I think about it; that is what Binary is all about.

Don't forget to visit Conjured Entertainment

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 25th May 2008 11:55
I use booleans alot with Ply's mod......

I have returned, after 28 days of exile, fear me!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th May 2008 12:08
Lol @ CG

But in Ply's Mod, you're not limited to 99 variables.


The one and only,


CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 25th May 2008 13:19
Self-advertising, are we?

I have returned, after 28 days of exile, fear me!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th May 2008 00:06
No no, just explaining why you have no fear of using lots of booleans.


The one and only,


Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 26th May 2008 04:44 Edited at: 26th May 2008 04:49
I think that 100 global variables are more than enough for a decent shooter with FPSC since so many things are built in.
I was concerned about how I used them when the number proposed was just five, but now we have a hundred I am not so pressed.

Have you guys built a game with his mod that uses more than 100 global variables?

I am not knocking the Mod or saying that more is not better, I am just curious if anyone has used more than 100.

Don't forget to visit Conjured Entertainment

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th May 2008 05:37 Edited at: 26th May 2008 05:39
Well, taking into account temporary variables used for calculations, as well as variables used to hold "internal" values or values shown on screen, I'd say given plenty of activities that require variable usage, you could easily surpass 100 or get pretty close to it.

Let's see how many I can come up with off the top of my head (Things I've already done/thought about doing):
1- Money
2- Discount variable for shops
3- Temporary Calculation variable for discount
4- Armor
5- Temporary Calculation variable for armor
6- Temporary Calculation variable for health
(From coffee grunt's scripts)
7- Health Packs
8- Health Pack calc var
9- Adrenaline Pills
10- Adrenaline Pill calc var
(For Vehicle script I made to test V1.07 of my Mod)
11- Max Velocity
12- Max Acceleration
13- Velocity
14- Acceleration
15- Temporary X variable
16- Temporary Y variable
17- Temporary Calculation variable for vehicle
(For Spy Bot script I made for 1.07)
18- Temp X Var
19- Temp Y Var
20- Temp Calculation var
(For Superpower Scripts)
21- Freeze Power activation variable
22- High Jump activation variable
23- Damage Multiplier variable
24- Increase Armor durability activation variable
25- Calculation variable for super powers
26- Second Calculation variable for super powers
(Leveling Scripts)
27- Player Current Level
28- Player Max Level
29- Player Experience
30- Player Needed Exp for next level
31- Calculation Variable for Experience
32- Calculation Variable for "Stats"
(Free Roaming Scripts)
33- Player Start location Variable

Let's stop there for now


Considering people will come up with tons more stuff to do with variables than I can think of right now, and the fact that we're already 1/3 of the way to 100, I'm willing to bet we'll be there in no time.

Personally, I'd be at ease knowing there is no limit than be required to not only keep track of how many I'm using but also what number each variable belonged to.


On top of not having a limit, if you're not using any variables, then they don't take up space. They're not predefined in my Mod and so, won't be taking up memory until they've been defined.

Add to that the fact that half of the aforementioned aren't possible with V1.09. And I'm not talking about vehicles/free roaming/armor/player statistics/super powers being possible in V1.09 either, I'm talking about you can't DO calculations with V1.09 if it's anything more complicated than adding and subtracting. Discounting the cost of an inventory item in a shop is pretty much impossible as you can't multiply/divide to find the appropriate percentage to be taken off.


And before we say anything about this, I'm not advertising for Ply's Mod... you just happened to ask the right question.


[EDIT]
For V1.09, take all of the values to be shown on screen (Money/Armor/Vehicle Fuel/whatever) and multiply it by the max number of digits you want to be seen, since in V1.09 there is no easy way to show things on screen. Using Conjured's method of displaying variables in V1.09 you're going to need a seperate variable for each digit in the "numeric hud".
[/EDIT]


The one and only,


CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 26th May 2008 14:07
....One word....PWNED......

I have returned, after 28 days of exile, fear me!
Aertic
17
Years of Service
User Offline
Joined: 2nd Jul 2007
Location: United Kingdom
Posted: 26th May 2008 22:46
Two words, HOLY SCRIPT!

Quote: "(Free Roaming Scripts)
33- Player Start location Variable
"


Nice, I'll use that for sure.

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 27th May 2008 00:51 Edited at: 27th May 2008 01:23
Quote: "Using Conjured's method of displaying variables in V1.09 you're going to need a seperate variable for each digit in the "numeric hud"."

My cash system only uses global variable #1 and #2 to display all six digits for the cash's value/display.
I have posted it for free in the Models and Media section if you want to take a look.
(You'll get a kick Plystire out of what is going on in there, but you know how it is)

I had originally thought that way too and had tried using local variables for counters etc but ended up not needing them.
You will see me initialize the local variables in the scripts.
I didn't take them out only because I got lazy and didn't feel like it since it doesn't hurt anything to leave it.


Quote: "One word....PWNED"

I wasn't being sarcastic or trying to compete with anyone, so that doesn't apply.
Sure Modded engines are better than stock, just like a race car.
You added features that enhance it, so it should naturally be better, and I am not here to argue that.
I was merely discussing the variables.

But he did confirm my suspicion that no one has actually used over 100 variables yet even with the modded engines.

Quote: "I'm willing to bet we'll be there in no time."

Me too, and I was wondering if we already had a first.

Don't forget to visit Conjured Entertainment

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th May 2008 01:58 Edited at: 27th May 2008 01:58
Well, I wouldn't really ask a modder if they've ever made an FPSC game using over 100 variables, because we quite honestly don't use FPSC enough to get there. We're too busy trying to make the engine better for everyone.

I do make scripts that use variables to test theories and ideas, and I do, from time to time, make demo games for some of the releases. (One of which I'll be making for the V1.07 release) They're not full games, and hence, wouldn't use as many scripts or variables as a full game might.

Another thought occurred to me as to what variables might be used for:

An Inventory System

Not like the one already supplied with FPSC, where you pick up an item and it goes into an inventory that you can't see, but a system where you can pick up an item and it goes into an inventory that you CAN see and use. I suspect such an inventory would require many variables, depending on how many items you'd want the player to be able to hold. (I'm thinking having a variables for each slot in the inventory, and whatever value each of those variables holds determines what item is within the slot. )


The one and only,


Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 27th May 2008 02:15 Edited at: 27th May 2008 02:26
Quote: " (I'm thinking having a variables for each slot in the inventory, and whatever value each of those variables holds determines what item is within the slot. )"

That sounds very logical, so don't be surprised to see similar systems.
Although the value limits easily exceed the number of items used.
So using 3 digits of the value for the item would leave 3 digits for the quantity.
Therefore, one slot could have up to 999 of any item of 999 items with one global variable using that system by using local variables for the breakdown.
Or you could just use two globals (1 for value 1 for item) for each slot and skip the breakdown altogether.
The pack shouldn't need more than 16 to 20 slots anyway, unless they are playing as a mule.

Don't forget to visit Conjured Entertainment

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th May 2008 06:29
Some nice intellectual exchange here. Thanks all for participating.

** We are not Alone **

Login to post a reply

Server time is: 2024-11-24 08:56:38
Your offset time is: 2024-11-24 08:56:38