Discuss Scratch

RickCall12
Scratcher
100+ posts

Tax Script

Hey guys.

I'm currently making a City Building game which requires the need for a Tax Script.

I've been practicing with a few, but they don't achieve what I need.
((Population / 2) + Money)
(Population * TaxRate)

What is want is, the population each pays a set tax rate, which can be defined by the player.
So if the tax rate is 5%, everyone pays 5% of their income.

How might I simulate all of this?
I haven't got a defined/predefined income yet, if its necessary.
I don't know, does anyone have any ideas for this?
coke11
Scratcher
1000+ posts

Tax Script

Hi,

It would really help if you could provide a link to your project.

Thanks!
coke11
deck26
Scratcher
1000+ posts

Tax Script

Not sure what the problem is - you store the current rate as a variable.

Tax paid = income * rate/100
Income after tax = income * (100 - rate) / 100
RickCall12
Scratcher
100+ posts

Tax Script

coke11 wrote:

Hi,

It would really help if you could provide a link to your project.

Thanks!
coke11
Sorry, here's the link
https://scratch.mit.edu/projects/71983440/
coke11
Scratcher
1000+ posts

Tax Script

Ok i will try to figure out later.
RickCall12
Scratcher
100+ posts

Tax Script

deck26 wrote:

Not sure what the problem is - you store the current rate as a variable.

Tax paid = income * rate/100
Income after tax = income * (100 - rate) / 100
That formula would work if the population in the game had a method of income, but I don't know how to simulate all of that yet.
deck26
Scratcher
1000+ posts

Tax Script

RickCall12 wrote:

deck26 wrote:

Not sure what the problem is - you store the current rate as a variable.

Tax paid = income * rate/100
Income after tax = income * (100 - rate) / 100
That formula would work if the population in the game had a method of income, but I don't know how to simulate all of that yet.
So the question was about simulating the income rather than handling the tax!

Presumably the income for the population can depend on various things - population size, (un)employment level, type of work available etc - so I'd start by thinking about things like that.

Last edited by deck26 (Aug. 1, 2015 17:34:05)

RickCall12
Scratcher
100+ posts

Tax Script

deck26 wrote:

RickCall12 wrote:

deck26 wrote:

Not sure what the problem is - you store the current rate as a variable.

Tax paid = income * rate/100
Income after tax = income * (100 - rate) / 100
That formula would work if the population in the game had a method of income, but I don't know how to simulate all of that yet.
So the question was about simulating the income rather than handling the tax!

Presumably the income for the population can depend on various things - population size, (un)employment level, type of work available etc - so I'd start by thinking about things like that.
Well.. I want a system that provides money based on the population.

Maybe I can have a look at the employment etc. But it might mean changing how the game functions.
wkelly42
Teacher
100+ posts

Tax Script

RickCall12 wrote:

Well.. I want a system that provides money based on the population.

Maybe I can have a look at the employment etc. But it might mean changing how the game functions.
If you just want money based on population, set income to something like 2 per person. Total income = population * 2, tax = total income *.05
RickCall12
Scratcher
100+ posts

Tax Script

whenIreceiveStartGameforeverwait10secswaituntilBuildings>1changeMoneybyAvgIncome/TaxeswhenIreceiveStartGameforeverwait10secssetAvgIncometo((PPWorkersEarn) + (GovernorsEarn) + (FarmersEarn)}setCHWageto((pick random (10) to (200))setPPWageto((pick random (10) to (150))setFarmWageto((pick random (10) to (100))setPPWorkersEarnto((PPWage) * (Population) / (10) * (PowerPlants))setFarmersEarnto((FarmWage) * (Population) / (10) * (Farms))setGovernorsEarnto((GovernorWage) * (Population) / (10) * (CityHalls))

I wrote these scripts to simulate incomes. There are some errors that I cannot identify. For instance, is sometimes changes the Money value to Infinity. When I checked some of the variables, some of the values were also Infinity. But I cannot identify where these are coming from.

(Sorry about the scriptblock errors above, I don't know how to fix these.)

Last edited by RickCall12 (Aug. 1, 2015 19:44:17)

RickCall12
Scratcher
100+ posts

Tax Script

wkelly42 wrote:

RickCall12 wrote:

Well.. I want a system that provides money based on the population.

Maybe I can have a look at the employment etc. But it might mean changing how the game functions.
If you just want money based on population, set income to something like 2 per person. Total income = population * 2, tax = total income *.05
I might try that formula if I can't get simulated incomes to work.
deck26
Scratcher
1000+ posts

Tax Script

Make sure that Taxes has a value before you run the ‘change Money’ block or you'll get a divide by zero error. Same with other calculations, anything you're dividing by must be non-zero.
KingCatboy90000
Scratcher
12 posts

Tax Script

Hey dude, I just made a tax calculator for the game, and I hope it helps

https://scratch.mit.edu/projects/72005248/
RickCall12
Scratcher
100+ posts

Tax Script

KingCatboy90000 wrote:

Hey dude, I just made a tax calculator for the game, and I hope it helps

https://scratch.mit.edu/projects/72005248/
Project isn't shared so I can't view it.
RickCall12
Scratcher
100+ posts

Tax Script

deck26 wrote:

Make sure that Taxes has a value before you run the ‘change Money’ block or you'll get a divide by zero error. Same with other calculations, anything you're dividing by must be non-zero.
Taxes have a default value of 5 but can be changed by the player.
RickCall12
Scratcher
100+ posts

Tax Script

Still having trouble with the script.

Tests have come up with “infinity” being added to the money, of which I don't know how to resolve.

Any way to fix this or should I try a different script?

Last edited by RickCall12 (Aug. 3, 2015 00:12:03)

RickCall12
Scratcher
100+ posts

Tax Script

Hey, I think I worked it out.

I made this project to help me, I think the problem with the original tax code was a lack of variables.

https://scratch.mit.edu/projects/72149214/#player

Powered by DjangoBB