How do Global Value of objects work?
If you set a global value according to an active object, how does it work? Because this is how my game is set up by far.
Global Value A - Changes Character you selected.
Global Value Z - Changes starting position of player in the frame.
Now, I have used the item collected code in my game where you collect an item, restart the frame, the item does not come back. It looks something like this
Run this event once
= Sppread Value 1 in Alterable Value A [Group.Collectables]
[color:#FF0000]On loop "items"[/color]
= Add 1 to Counter
[color:#FF0000]On loop "items"[/color]
+ Global Value(value("counter")) = 1
+ Alterable Value A of [Group.Collectables] = Value("Counter")
= Destroy [Group.Collectables]
Apparently, when I collected one of the items I have in my game (health power up in this case), it changed my character due to the global values being the same? That's what I figure anyway.
Though the other different items I have when collected (lets say, 1-up in this case), do not do this to my character.
So with that in mind, am I using multiple global values here just for this feature? When I did more testing, and reset only one or two global values on the stage select frame, one of the items came back in the level frame, while the other items did not come back.
So, I'm wondering, is it possible for me to use ONE global value just for ALL items whether its a 1-up, or power up? Or do the global values have to be different depending on what the power up/collectable item is?
Example:
Global Value B - 1-ups, health power ups, weapon power ups.
Or does it have to be like this
Global Value B: Health Power Up
Global Value C: Weapon Power Up
Global Value D: 1-up
Keep in mind I have used the Group.Collectables qualifier for my power ups in my game. So I'm trying to figure out a way to correct this if possible.
Re: How do Global Value of objects work?
You will need a different Global value for each.
Marv
Re: How do Global Value of objects work?
For a store of multiple objects, you're probably better off spreading a value in them and then recording their picked-up state in some sort of array.
Re: How do Global Value of objects work?
What?
Global values are GLOBAL, you can't use the same one for multiple objects unless you want them to actually use the same value.
Global Value A = Global Value(0), so if you actually used the globals starting from 0 this is why it overwrote your global value A and changed your character.
Something like this should work: (using the global values starting at 50)
Start of frame:
= Spread Value 0 in Alterable Value A [Group.Collectables]
Start of frame:
= Start loop "items" for count("Group.Collectables") loops
On loop "items"
+ Global Value(loopindex("items")+50) = 1
+ Alterable Value A of [Group.Collectables] = loopindex("items")
= Destroy [Group.Collectables]
Also notice me using the built-in loopindex() instead of a counter.
Re: How do Global Value of objects work?
Quote:
Originally Posted by Dynasoft
What?
Global values are GLOBAL, you can't use the same one for multiple objects unless you want them to actually use the same value.
Global Value A = Global Value(0), so if you actually used the globals starting from 0 this is why it overwrote your global value A and changed your character.
Something like this should work: (using the global values starting at 50)
Start of frame:
= Spread Value 0 in Alterable Value A [Group.Collectables]
Start of frame:
= Start loop "items" for count("Group.Collectables") loops
On loop "items"
+ Global Value(loopindex("items")+50) = 1
+ Alterable Value A of [Group.Collectables] = loopindex("items")
= Destroy [Group.Collectables]
Also notice me using the built-in loopindex() instead of a counter.
Shouldn't your Start loop "items" for count("Group.Collectables") loops read like this instead?
Start loop "items" NObjects("Group.Collectables") times.
Anyway...... I used this format, and he STILL changes into another character (from global value A) when I pick up a health power up.
Not to mention that the items I picked up come back when I restart the frame. X_X
Re: How do Global Value of objects work?
You can use the associative array and set the key to Health (for example) and set it to 1.
Your character picks up Health Power up
>Set Global Value A to 1
>Health Power Up: Destroy
>Associative Array: Set Health to 1
Next event
If Health = 1
>Health Power Up: destroy
This way the health power up will be gone
Save the associative array.
When you restart the frame load the associative array if Global Value = 1.
Marv
Re: How do Global Value of objects work?
Actually.... I'm trying to make a game engine with as little to no extensions as possible. Even if they are Clickteam's own, or extensions built with the software. X_X
But I don't think that would be possible, even for when it comes time for me to set up a save feature, which would require INI to handle, I'd imagine. X_X
Re: How do Global Value of objects work?
I have a INI++ example on my website that saves global values. I know you don't want to have to use extensions, but it sure makes life easier for the programmer.
Good luck on your engine.
Marv
Re: How do Global Value of objects work?
Quote:
Originally Posted by N64Mario
Shouldn't your Start loop "items" for count("Group.Collectables") loops read like this instead?
Start loop "items" NObjects("Group.Collectables") times.
Yes, I was typing it from memory...
Quote:
Originally Posted by N64Mario
Anyway...... I used this format, and he STILL changes into another character (from global value A) when I pick up a health power up.
Not to mention that the items I picked up come back when I restart the frame. X_X
My guess would be a problem with where you are SETTING the global value then. Something like:
Player collides with Group.Collectables
= Set Global Value(Alterable Value A of [Group.Collectables]+50) = 1
= Destroy [Group.Collectables]
(relying on the spread value from the original code)
Though I admit that I don't know whether "spread value" works on a whole group or just spreads the same value in each object in the group.
Re: How do Global Value of objects work?
It spreads it on all objects Im sure