Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Tabula Rasa Collection help! I cannot accurately track the gems

#1

Okay so I’m on Tablua Rasa on the first game development path here is my code so far

# Create your own game!
game.spawnMaze("forest", 4)

# Player Character
player = game.spawnPlayerXY("samurai", 10, 60)
player.maxHealth = 250
player.maxSpeed = 7
player.attackDamage = 10

# Goal to beat the game
game.addDefeatGoal(16)
game.addCollectGoal(20)

# UI Tracking
ui.track(player, "health")
ui.track(game, "defeated")
ui.track(game, "collected")

# Gems
gem1 = game.spawnXY("gem", 30, 60)
gem1.value = 1
gem2 = game.spawnXY("gem", 44, 60)
gem2.value = 1
gem3 = game.spawnXY("gem", 60, 60)
gem3.value = 1
gem4 = game.spawnXY("gem", 12, 43)
gem4.value = 1
gem5 = game.spawnXY("gem", 12, 14)
gem5.value = 1
gem6 = game.spawnXY("gem", 28, 29)
gem6.value = 1
gem7 = game.spawnXY("gem", 45, 12)
gem7.value = 1

chest = game.spawnXY("chest", 60, 12)
chest.value = 150

# Munchkin Generators
mygen1 = game.spawnXY("generator", 27.5, 44)
mygen1.spawnType = "munchkin"
mygen1.spawnAI = "AttacksNearest"
mygen1.maxHealth = 65
mygen2 = game.spawnXY("generator", 28.5, 12)
mygen2.spawnType = "munchkin"
mygen2.spawnAI = "AttacksNearest"
mygen2.maxHealth = 65
mygen3 = game.spawnXY("generator", 52, 27)
mygen3.spawnType = "munchkin"
mygen3.spawnAI = "AttacksNearest"
mygen3.maxHealth = 65

# Extra forest blocks
game.spawnXY("forest", 52, 60)
game.spawnXY("forest", 20, 28)

I am having trouble with it tracking the gems collected and ive went back in to the previous levels and cant figure it out I’m stuck please help

#2

Please send a screenshot and a description of the errors that you get when you run your code. Also a screenshot of your inventory would help given that

Thanks!
:fox_face: :fox_face::fox_face:
@Luke10

#3


up in the upper right hand corner the

ui.track(game, “collected”)

is displayed and in theory it is suppose to track the gems as you collect them but it does’t, and the tracking of the enemy’s defeated is working just fine, there is no inventory system its in the first game development path the very last level. When I run the code I get zero errors and the game runs just fine its just when i pick up the gem it doesn’t track on the UI.

#4

Are you sure you have the exact and precise locations of the gems? Double check your code and make sure the locations are correct.

Also sometimes what happens in a level like this is your hero will bump into obstacles along the way. Sometimes you will have to put in coordinates away from the obstacle to ensure that the hero does not hit the obstacle. Try that also

1 Like
#5

I will try and move the gems further away but I can pick them up just fine they just don’t get tracked on the UI

#6

It may be a glitch or bug problem. Contact @Chaboi_3000 or @Harry_the_Wanderer. Restarting your computer may help.

#7

I think you need to use Game.on("collect",Actionname)

1 Like