• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Script that adds money every 4 seconds after placing an object

M

Monter

Guest
Hello, I'm working on a tower defence game. Starting money is set to 200. Except towers I want to build mines that gain 25 gold every 4 seconds. I have no idea how to write a script for this.
 
W

Walky

Guest
One possible way to do this is to create a 4 seconds Alarm event that adds 25 gold and then calls itself.
 

FrostyCat

Redemption Seeker
Blindly copying code off tutorials is a sin for coders. If you paid attention to how you did rate of fire for your towers, you shouldn't need to ask for this.

Your towers should have code setting an alarm or a manual countdown variable, and firing and resetting the alarm/countdown when the interval elapses. This is no different, except the interval is 4*room_speed and the action is adding 25 to gold.
 
Top