Timer not accepting real number from game attributes?
I'm hoping someone else may have run into this problem and have a solution:
I am working on a game where actors enter from offscreen at random. I am creating this by having a game attribute "GO" be set to a random number between 1-12 every X second, where X is another REAL game value called Spawn. When an actor's number comes up, they have a rule that sets move to "on", and they enter.
I am trying to create a system where by every 10 points, the speed of the spawn increase by 5%. So I have an actor that, for every ten points earned, sets the game attribute Spawn to Spawn*.95. This works great and the value is accurately being reduced by 5%. However, the actor that spawns the other actors will only accept the value that I set the Spawn attribute initially. It won't accept any of the subsequent reduced values.
If I manually enter a value in the spawn time within the spawning actor it works great. As soon as I tell it to pull from the Spawn game attribute, it will only use the initial set value. This won't work for me because, for every ten points the actors entering speed up 5%. So if I lock the spawn rate, the actors will eventually be spaced farther and farther apart.
Any ideas out there?
I am working on a game where actors enter from offscreen at random. I am creating this by having a game attribute "GO" be set to a random number between 1-12 every X second, where X is another REAL game value called Spawn. When an actor's number comes up, they have a rule that sets move to "on", and they enter.
I am trying to create a system where by every 10 points, the speed of the spawn increase by 5%. So I have an actor that, for every ten points earned, sets the game attribute Spawn to Spawn*.95. This works great and the value is accurately being reduced by 5%. However, the actor that spawns the other actors will only accept the value that I set the Spawn attribute initially. It won't accept any of the subsequent reduced values.
If I manually enter a value in the spawn time within the spawning actor it works great. As soon as I tell it to pull from the Spawn game attribute, it will only use the initial set value. This won't work for me because, for every ten points the actors entering speed up 5%. So if I lock the spawn rate, the actors will eventually be spaced farther and farther apart.
Any ideas out there?
Comments
A workaround I can think of - which surely should work, is make another real attribute and after
Change attribute Spawn to Spawn*.5
---put---
Change attribute NewRealAtt to Spawn
then have your actor that spawns the other actors call on NewRealAtt rather than Spawn
Still odd though what's going on...
Edit: hang on, just thought... not totally clear about your rules from your explanation but maybe you need a constrain attribute somewhere if a Timer is involved...
----------------------------------------------
http://davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks for the input. At first, I thought that I may have duplicated the attribute, so I created a new one, deleted the old one, and pointed all rules to new attribute. Granted, that may have inadvertently recreated the loop somehow.
I'm still new at GS. What do you mean by constrain attribute?
Thanks!
Get I sometimes words my as well up mixed... ;-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Also:try the following as a test: where you have the Stop repeating Random Bldg GO Numbers Rule, ignore (and delete) the timer and drag the When self.NewNum = self.OldNum then Change att. Self.NewNum to random(1,12)... underneath the Change Self Old # to the New # attribute.
Finally, neither of those might not help without me actually experimenting, but one thing's for sure: you're very first Attribute, Change Bldg GO New Number ... change att. self.NewNum to random(1,12) ... only happens once, so it'll always be the one number...
Hope that's helpful for you and I haven't muddied the waters as it were.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Bacon, the Spwn_Time attribute isn't the random one. That is set as a real number attribute (say 3) and is reduced by 5% for every 10 points the player score. This time triggers the actor pictured above to generate a random number from 1-12 that tell the appropriate actor to start to move. (confusing I know.) I was doing this whole exercise because, with every 10 points, the actors coming on screen speed up by 5%. If I lock the spawn time, they continually get farther and farther apart as they enter. I was hoping that by reducing the spawn time proportionally, they would all keep a relative distance from each other at any speed.
Thanks all for your help so far. Any ideas on how to pull off what I blathered on about int paragraph two, would be appreciate!
EDIT: So I created a brand new actor with the plain Jane rule below. Using 2 display text actors, I can verify that the Spwn_Time variable is reduced as expected (I set it to 50% to make sure it would be perceivable.) and the Bldg_GO attribute is still only using the initial variable that I type into it. I verified this by typing multiple values there and testing all with the same result. It is as if I can't right that attribute. Is this possible in GS? To write protect an attribute? Is there and attribute limit I don't know about?
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Still, I've had another look at your Rules and it's clicked to what you are trying to do. I re-ruled it as below, so you don't need self.Old number to trigger the repeated random:
Timer:
Every game.Spwn_Time
Change Attribute self.New Number to random(1,12)
Constrain Attribute game.Build_Go to self.NewNumber
THe constrain att. behavior might still work with change attribute.
Hope it helps.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
EDIT: Typed this as Gyro was responding. Let me try that as well.
I'll take another look tomorrow with a fresher mind and see if I can help anymore; but in the meantime hopefully someone else will be able to help before that.
PS the re-ruling I gave does give a random number every so many seconds for certain, but if you're using real attributes, I doubt there'll be many matches... self.NewNumber would have to be an integer. But perhaps in my sleepy head I've misunderstood...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
The attribute Spwn_Time isn't being setup by a random number. It is a real number game attribute that I have set to a specified number to start. Ex. 3. The random number comes in the form of the integer game attribute BLDG_GO.
So, what should be happening in the actor I am using to spawn my other actors is:
Every (Spwn_Time, 3 in this example) seconds, change BLDG_GO to a random(1,12)
This works for the initial value. So if I set it to 3, it will randomize every 3 seconds. If I set it to 5, it will randomize BLDG_GO every 5 seconds.
The Spwn_Time can be reduced by a specified percentage at a given time by a separate actor using a rule that:
If Points X is >= (Points X +10) then change game.Spwn_Time to game.Spwn_Time*.95 (This would be a 5% decrease.)
I have been able to confirm that this mechanism works correctly with a actor displaying Spwn_Time's value in my scene.
The problem comes in that the timer in the spawing actor doesn't recognize that Spwn_Time is changing. No matter what Spwn_Time changes to, it will still keep randomizing at whatever Spwn_Time's initial value is set at.
Now, to make it weirder, say I change BLDG_GO timer to be:
Every (Spwn_Time+Spwn_Time, 6 in this example) seconds, change BLDG_GO to a random(1,12)
the timer will correctly randomize for the 6 seconds, so it recognizes the attributes value. However, it again won't recognize any of the subsequent values once Spwn_Time is reduced.
I hope that helps explain the mess a bit better.
In this project, every time you hit the space bar you get 5 points. For every ten points, the Spwn_Time is cut in half. So it is pretty easy to see when Bldg_GO isn't speeding along at the pace it should.
http://www.ellfireproductions.com/images/SpawnIssue_Test.zip
I've looked at your gamefile, get what you're after and it looks like I've got it working as you want. (I think I misunderstood a lot yesterday in my bleary state...!) Basically I've put a boolean switch for it to toggle every time the game.Spawn_time changes. The only changes I made are in the Random_Build_Go rules.
http://dl.dropbox.com/u/14060718/SpawnIssue_TestDGamend.gameproj.zip
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Thanks for your reworking, Gyro. I downloaded the one from your link, but I can't seem to find any changes in it. (Can't find the boolean your talking about in the game attributes and everything seems the same in the Random_GO actor.) Not sure if this was the file you tweaked? Thanks again for taking the time out to help out here.
Take 2:
http://dl.dropbox.com/u/14060718/SpawnIssue_TestDGamend 2 send.gameproj.zip
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I opened it up (after making sure that the first one I downloaded was gone and restarted GS.) and all is still looking the same.
Here is a screen grab of what the game attributes and Random_Build_GO still look like. Maybe I am missing it.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
So, how does this do it's magic exactly? No worries if you don't want/have time to explain it, but I think it might help other folks as a work around. My little noggin can't figure it out because you are still using the Spwn_Time expression in the timers? How does the SceneOnOff boolean trick it into working?
Actually, it's very straightforward: first to say that a Timer will only work with the time as a fixed value. It'll do it's thing - Every, For or After based on the first value of an attribute and there's no way of changing that based on a new value if the attribute changes. So basically we've got to get around that problem. (I'm sure my solution isn't the only way but I guess any other solution would have to do the same thing, i.e find a way to run a Timer that changes the time values, er....over time...
So I made a boolean and called it OnOff. this acts just like a toggle/switch. So because it's default value is set to 0, false or first state depending on how you want to look at it, I used that one first. So when OnOff is false then the Timer with your first value of Spawn_time does it's random and make the boolean On/Off true after it's finished.
And when it has finished that, the When OnOff is true kicks in, and off it goes again with the 2nd Rule time value of Spawn_time, and only when that's finished does it make the boolean OnOff false again. So the first Rule kicks in again: "When OnOff is false", this time with the next time value (Spawn_time; and when finished its random, OnOff is set to true again, etc, etc, looping from one Rule to the other, with Spawn_time a different value each time.
So there you go, it's all smoke and mirrors and it's a simple process really! Glad your problem is solved! :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps