Cloudrip Siege: I need help with my code

I don’t get what you mean so can you explain it a little better?

The last version of the code you posted has three problems:

Problem One: (I think you may have fixed this one already)

hero.buildTypes = ["decoy", "arrow-tower"]

You can’t change the hero’s buildTypes. If you want to just make a list of stuff you want to build you would make a new list for that, something like this: myBuildTypes = ["decoy", "arrow-tower"]

Problem Two:

hero.buildXY("buildType", hero.pos.x, hero.pos.y)

You can not build a “buildType”, there is no such thing as that. You are setting the variable buildType to “decoy” or “arrow-tower”, so pass the variable buildType to the buildXY function. In other words, you want this:

hero.buildXY(buildType, hero.pos.x, hero.pos.y)

Problem Three:

if hero.gold >= buildType:

This is always false, I think you want to check if hero.gold is greater than or equal to the cost of buildType

if hero.gold >= hero.costOf(buildType):

Ok thank for explaining it.:slightly_smiling_face:

When I made these three changes to your code it was running and building decoys and arrow-towers, good luck!

Thank lot @Mr-Borges I’m try the code now.

Sorry I press the wrong button.

1 Like