Timer not accepting real number from game attributes?

ellfireellfire Member Posts: 187
edited January 2012 in Working with GS (Mac)
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?
«1

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Hi elfire, I personally can't think of a reason why your updated attribute Spawn isn't getting through to your actor that spawns the other actor... that seems crazy, in as much as an attribute value, when changed becomes that value and the value before is totally gone, as you know. The only thing I can think is you've duplicated your attribute called Spawn and the actor that spawns the other actor is referred to that one. Another thing that could affect it is loading attributes...maybe that's in there somewhere...

    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

  • ellfireellfire Member Posts: 187
    Gyroscope,
    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!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Sorry, a constrain attribute behavior I meant!

    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

  • ellfireellfire Member Posts: 187
    Nope still not working even with a new attribute. It really is as if the time cannot see the expression but accepts a digit. I need to see if this is so with other timers in the project.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Would you mind posting a screen shot of the Rules or write them, those that involve the Timer?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ellfireellfire Member Posts: 187
    edited January 2012
    Here is how I have the rules set up for the actor that generators the random number from 1-12 and saves it to the attribute that triggers the other actors to start moving. It is a frankenstein with one of TSB's tutorials to avoid duplicate numbers. In trying to eliminate that, I had created a new actor that was litterly just a stimer point to game.Spwn_Time for its seconds value and it still wouldn't work.

    image
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    As far as I can make out, you'll possibly need the Run to Completion checked in the Every game.Spwn_Time Timer.

    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

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2012
    What's telling game-spawn-time to be random? I don't see any code to create the random time. And Gyro is right that first change attribute needs to be in a timer set to every- what ever seconds you want. So where ever the change attribute for you game level random spawn time is, check to see if you put that in a timer too or it will only pick a number once.
  • ellfireellfire Member Posts: 187
    edited January 2012
    Thanks, Gyro. Well, still nada. I tried what you outlined, zilch. I tried setting the NewNum attribute by putting it under the timer that uses spawn time, again, holds the initial value and that's it. This is crazy! I think the only way I can get to the bottom it it, and hopefully not find it to be a bug in the new GS version, is to start over from scratch on this piece with all new variables. Grrrr....

    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?

    image
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Did you try checking the run to completion?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    That could help as FBS says.

    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

  • ellfireellfire Member Posts: 187
    edited January 2012
    Yeppers. No dice. Now, if I were to put in Spwn_Time+Spwn_Time into the expression with Spwn_Time = 3, it'll spawn for 6 seconds, but, when reduced, it sticks with six instead of going to 3. (Again, using a 50% reduction to make sure I could see a change.) It is like the time is getting the value from whatever expression is in there and then holding on to it.

    EDIT: Typed this as Gyro was responding. Let me try that as well.
  • ellfireellfire Member Posts: 187
    Thanks, Gyro. I tried your setup and still zilch. Should I file this as a bug issue with the powers that be somehow?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    No, I'd suggest, it's not a bug I don't think; it's something going on with the ruling, I'm almost certain. I'd be more sure what was going on if I saw your gamefile but I'm off to sleep in about ten minutes or so...

    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

  • ellfireellfire Member Posts: 187
    Coolness. Thanks for all your help, Gyro. G'Night.
  • ellfireellfire Member Posts: 187
    So in this ongoing quest, I created a completely new real attribute to replace Spwn_Time and a completely new integer attribute for BLDG_GO and setup a completely new actor like the simple one above. I know that none of these attributes are referenced anywhere outside of the actor that reduces it by x%, this actor, and two display text actors that each show the value of each one. The same exact thing is happening. As this was created with two brand new and independent attributes from the originals, I have no idea what is going on. Timer is just acting weird for some reason.
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    Are you talking about the game.spwn_time thats not working, then you should show us how to get the value of spwn_time attribute. The pic you showed us doesn't tell us anything about how you setup spwn_time??
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    If you are setting game.spwn_time with a random expression Randoms only output integers. Just FYI I have not read through the entire thread so maybe you have explained differently already.
  • ellfireellfire Member Posts: 187
    hi, GL and tendrmer,

    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. :\

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Ah yes. Now I understand I remember a while back a bug showing up where the timer does not adjust itself when the attribute being referenced for the time changes. Unfortunately i'm not sure if it turned out that was actually s bug or If they changed how the timer handles the attribute. Be sure to send in a bug report if you have not already. make sure they realize the main issue is the timer only runs based on the original value of the attribute.
  • ellfireellfire Member Posts: 187
    edited January 2012
    Okay. I am starting to agree with tendrmer. I created a stand alone project posted to the link below. I setup the basic system I outlined above. And even in this simplified state, the timer recognizes the initial value but not subsequent changes. If anyone would like to give it a look see and check that I am not missing something obvious, that would be great. (I'm still new at GS.)

    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
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    strange indeed i think my game http://itunes.com/apps/meteorbash2 uses the same way to change the spawn spd and drop spd. somehow it seems to work but i cannot be sure cos i'm only changing the timer by subtraction.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    @tenrdrmer is correct about an attribute in a timer; it can't be variable. Not sure if that's a bug as such or just the way it is... for certain it's been like that for quite a while now and either way, GS HQ are aware of the issue.

    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

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I love these forums as so many are willing to give a bit of their time to do such things! It's what's inspired me to do my part as well. Like the Unoffical gsguide and such.
  • ellfireellfire Member Posts: 187
    Thanks for all the clarification everyone. At least now I know I'm not going crazy!

    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.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Hi elfire, not only am I not with it at the end of the day, but obviously at the beginning too! I sent you your file back, not the amended one, as you guessed... sorry about that!

    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

  • ellfireellfire Member Posts: 187
    edited January 2012
    No worries at all, Gyro...but I think that is still the same file. :)

    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.

    image
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    You got me there for a minute.... I should have said, I've changed the rules in the actor Random_Build_GO on screen, not in the prototype... :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ellfireellfire Member Posts: 187
    Ah HA! I new I missed something. Rockin'. This seems to be working great, Gyro. Thanks a bunch.

    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?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Oh yes, all magic it is! ;-)

    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

Sign In or Register to comment.