does this timer make sense to you guys?

I found out how to make the coins spawn in a line (link:https://forums.gamesalad.com/discussion/51961/how-to-spawn-coin-lines)

Thing is, I want my coins to stop spawning and then in like a random time lets say 5,8 seconds it spawns a coin line for 4 seconds. And then in it stops for 5,8 seconds then starts spawning a line of coins only for 4 seconds. I just thought it would a simple timer.. Like adding another timer.
I tried
Timer : every random(5,8) seconds
Timer : for 4 seconds
spawn coins
... that timer makes sense to me.. but when I try it, it only spawns one coin every random(5,8) seconds.
Idk if I should make a boolean or something?
Thanks :)

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    Yeah, timers don't work with 'every random (1,20)' - they just generate a single random number the first time and then loop on that number . . . .

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    Here's a quick 'every-random-seconds-spawn-something' timer:

    https://www.mediafire.com/?d151h5bmw98bws9

  • SocksSocks London, UK.Member Posts: 12,822

    Damn, just noticed you are on a PC, my demo file is Mac, hold on let me take a screen shot, it's a simple enough bit of cod . . . .

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    Code below . . . . the only other thing you'll need is a game.attribute that this code references - in the example here the game.attribute is called 'Random'.

  • ArmellineArmelline Member, PRO Posts: 5,365

    Although Sock's method is great, there are two other alternatives.

    Check the project file below. I'm pretty sure I actually learned one of them from @Socks...

    All three methods are entirely valid, and each has minor strengths in certain fringe circumstances.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks and @armelline hey guys I just saw this! I just came back from an all day road trip. So first thing in the morning and I'll try them out & give you guys feed back if that's okay?

    but thanks really appreciate taking your time to help me with is :)

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @Armelline‌ Hey I just downloaded your template! thanks for taking your time! but if you don't mind could you tell me the difference between the two and the advantages and disadvantages?
    @socks for the game.random is that a real or integer? also do I give it a value? because it didn't work. I thought it might be an integer because it's not really keeping trap of a position. Ill type out what I have set up for my spawner

    Timer: Every 5 seconds
    change attribute : game.random X (for coins) to: random (60,500)

    Here's the rule I updated based of the picture you just posted. I'm not sure if I type it out properly .

    (Also that timer was just to keep track of my random so it changes the coin's spawning position every 5 seconds.)

    Timer: After game.random (timer for coins)

    change attribute : game.random (timer for coins) to random(1,3)

    Spawn actor: coin : in front of actor. In the direction 270 relative to scene
    from position : random X (for coins) , 344 relative to scene

    Destroy this actor

    Spawn actor: coin : in front of actor. In the direction 270 relative to scene
    from position : random X (for coins) , 344 relative to scene

    That's the coding I'm using @socks . Sorry for it being really long I don't know how to post pictures on here.

    (also the "()" at the end of all my attributes I put it there so I know which one is which. Because sometimes I make a bunch of Player X's and Player Y's and I get confused easily with stuff like this LOL)

    Thanks again @socks and @armelline

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @vnwadike13@gmail.com said:
    socks for the game.random is that a real or integer? also do I give it a value? because it didn't work. I thought it might be an integer because it's not really keeping trap of a position. Ill type out what I have set up for my spawner

    [real or integer] It can be whatever you want, but as the random function only produces whole numbers you may as well make it an integer.

    Its default value is 0 (like every other numerical attribute), but you can make the initial value whatever you like/need. The initial has no actual effect on the code - as the first thing the code does is change game.random to a random number !

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks is there a way with my second problem?

  • SocksSocks London, UK.Member Posts: 12,822

    @vnwadike13@gmail.com said:
    socks is there a way with my second problem?

    I can't see a second question.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    Timer: Every 5 seconds change attribute : game.random X (for coins) to: random (60,500)

    Here's the rule I updated based of the picture you just posted. I'm not sure if I type it out properly .

    (Also that timer was just to keep track of my random so it changes the coin's spawning position every 5 seconds.)

    Timer: After game.random (timer for coins)

    change attribute : game.random (timer for coins) to random(1,3)

    Spawn actor: coin : in front of actor. In the direction 270 relative to scene from position : random X (for coins) , 344 relative to scene

    Destroy this actor

    Spawn actor: coin : in front of actor. In the direction 270 relative to scene from position : random X (for coins) , 344 relative to scene

    That's the coding I'm using @socks . Sorry for it being really long I don't know how to post pictures on here.

    (also the "()" at the end of all my attributes I put it there so I know which one is which. Because sometimes I make a bunch of Player X's and Player Y's and I get confused easily with stuff like this LOL)

    Thanks again @socks and @armelline

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks can you see it now? I can inbox it to you if that'll help

  • SocksSocks London, UK.Member Posts: 12,822

    @vnwadike13@gmail.com said:
    socks can you see it now?

    No, I am looking for a sentence ending with a question mark, still can't see it.

    @vnwadike13@gmail.com said
    I can inbox it to you if that'll help

    How would that help ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks that was my 2nd question I just wanted to know if that code made sense because that it wasn't working

  • colandercolander Member Posts: 1,610

    @vnwadike13@gmail.com said:
    Sorry for it being really long I don't know how to post pictures on here.

    Take your screen shot zip it then upload it. If you don't zip/compress it GS won't let you upload it.

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @vnwadike13@gmail.com said:
    socks that was my 2nd question I just wanted to know if that code made sense because that it wasn't working

    Can you be any more specific than 'it wasn't working' ? I could trawl through your code looking for the issue, maybe too many coins are spawned, maybe they are not being spawned randomly, maybe 2 coins appear at once, maybe they are rotated upside down or too small or they delete themselves after 1 second or maybe an 'invalid expression' comes up when you run the code or . . . . . or a thousand other things ! : )

    I presume you actually know what the issue is, so why not tell me, it seems like the obvious thing to do to me . . . . anyhow I will take a look and see if I can see what the problem is - this really is the very very very very slowest way to get problems addressed !!

    :neutral_face:

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    Ok this is your code with as much as of the confusion removed as possible :)

    . . . . . .

    Timer:

    Every 5 seconds

    Change attribute: _Random X_</font color> to random (60,500)

    . . . . . .

    Timer:

    After _Random_</font color> seconds

    Change attribute: _Random_</font color> to random (1,3)

    Spawn actor: COIN : X position = _Random X_</font color>

    Destroy this actor

    Spawn actor: COIN : X position = _Random X_</font color>

    . . . . . .

    Ok, from what I can see your code spawns two coins in the same position . . . is that what is happening ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks here you go! sorry I don't know how to zip and compress I'm not really use to that complicated stuff to upload photos. I googled it but I decied to phototbucket it because I see a lot of people have a photobucket. Thanks for your time btw Thanks bro I owe you one

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @vnwadike13@gmail.com said:
    socks here you go! sorry I don't know how to zip and compress I'm not really use to that complicated stuff to upload photos.

    I think you are confusing me with Colander, I've not asked you to zip or uploading anything ?

    Did you read any of my posts above, the one that starts with "Ok this is your code . . . " - or the one that starts "Can you be any more specific . . . " ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks yeah I did and I put in the coding exactly like you did. But for some reason it didn't work. But I think the problem is the "destroy" behavior in the timer. Would you mind trying that coding on your computer and see if it spawns properly? (and also what was the reason for the second spawn?)

  • SocksSocks London, UK.Member Posts: 12,822

    @vnwadike13@gmail.com said:
    socks yeah I did and I put in the coding exactly like you did. . .

    I've not actually asked you whether you put the code in like I did - that code I typed out was the code you posted ! I know that is what you used as I copied from you !

    Ok, last attempt . . . . :)

    Can you be any more specific than 'it wasn't working' ? ("I presume you actually know what the issue is, so why not tell me?")

    "Ok, from what I can see your code spawns two coins in the same position . . . is that what is happening ?"

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks I put in the code according to the picture you posted on the 19th. Now when I in that code it doesn't work it only spawns one coin that's it. It never spawns the coin again. If I knew what the issue was I would have told you what it is by now or I would have tried to figure it out by my self. Now a days I only come on the forums to address issues I can't figure out by my self because I know you guys have tons of other people asking other questions.

    Again @socks the code that I typed in was based on the photo that you posted. And what happens when I put in the code based of the picture you posted is it only spawns one coin and never ever spawns another coin. The photo you posted I presumed that was the code to figure out the "start stop spawn". But again it only spawns one coin. Rather than spawning a row of coins stopping for like 5 seconds and resume spawning again in a different X location. I want it to keep doing this through out the game. That's the effect I'm looking for

    I don't know how to be more specific than this. :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @vnwadike13@gmail.com said:
    If I knew what the issue was I would have told you what it is by now . . .

    But you do know what the issue is ! You have just told me ! The issue is that it only spawns one coin, then it never spawns the coin again - up until now you've kept the issue secret for some reason !? You've known this from the start, so why not share that information with people you are asking for help from !?

    If you were to tell me this in the first place then I'd have somewhere to start, like I say just posting a whole load of code and leaving people to guess what the problem might be is the slowest way to resolve issues.

    @vnwadike13@gmail.com said:
    I don't know how to be more specific than this. :)

    You don't have to be more specific than that, I was simply asking you to tell me what the issue was but if you are going to ignore my questions and keep the issue secret it's always going to be an uphill battle to help anyone out ! :smiley: Posting a whole bunch of code and saying "this doesn't work" isn't much use to anyone, but posting the same code and saying "this is meant to do X, Y and Z, but is only doing X and Y" gives people somewhere to start.

    Your problem is that you've not followed the code I posted, take a look through it and copy it exactly. I'll give you the answer if you want, but I think it's best if you take a close look at the code, it will help you understand how it works.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    Okay @socks :smiley:
    so what you're telling me is that I should follow the code exactly like how you posted it in that photo and it should work?.. I did that BUT let me take sometime out and see if I missed anything! Thanks bro!

  • SocksSocks London, UK.Member Posts: 12,822

    @vnwadike13@gmail.com said:
    Okay socks :smiley:
    so what you're telling me is that I should follow the code exactly like how you posted it in that photo and it should work?.. I did that BUT let me take sometime out and see if I missed anything! Thanks bro!

    If you are still struggling then I'm happy to point out the mistake - but give it a go, it'll help you see how the code works.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks I made some improvement after like an hour. but there is a little hick up. I'll tell you what I changed. I said:

    Timer:

    Every 5 seconds

    Change attribute: Random X to random (60,500)

    . . . . . .

    Timer:

    After Random seconds

    Change attribute: Random to random (1,3)

    Timer:

    Every 0.5 seconds

    Spawn actor: COIN : X position = Random X

    I got rid of the second spawn and the destroy. Now when I press "play" what it does it spawns a lot of coins I would say around 15 coins in a straight for about 5 seconds which is exactly what I'm looking for! BUT after the first 5 seconds of the game and the first line of coins spawn when it stops to change position (I'm assuming) it never spawns again! So idk if the timers are clashing together.

    Hope you get what I'm trying to say

    Thanks :smiley:

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    What I'm basically trying to say is that it doesn't spawn a second line of coins and so on. It only spawns one line of coins and stop completely and tbh IDK what to do to @socks

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    Rule for SPAWNER.

    Timer

    After X seconds

    Change X to random (1,3)

    Spawn COIN wherever you need it.

    Destroy this actor

    Spawn SPAWNER

Sign In or Register to comment.