Edit data in database

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Akuma

trying to edit HP causes an error, I’m new, not sure how to achieve it. help is appreciated
Edit: I have multiple of those and everything besides the boolean should be swappable

export var Players = {
	1 : {
	"maxHP" : 5,
	"HP" : 5,
	"Speed" : 100,
	"Stopped" : true
    },
	2 : { 	
    "maxHP": 5,
	"HP" : 5,
	"Speed" : 100,
    "Stopped" : true
    }
}

How are you trying to edit the value (post the code)? What is the error, exactly?

jgodfrey | 2022-12-09 14:04

I posted that in the other reply just now

Akuma | 2022-12-10 03:30

:bust_in_silhouette: Reply From: aXu_AP

I’m not sure what you have tried to do in order to modify HP, but this is how you can modify player 1’s HP:

Players[1]["HP"] = 4

hmm… I’m not sure why it didn’t work at the beginning

was using a global variable
Game.Players[Game.target].Speed *= 0.5
where target is an int

was also using it this way

for i in Game.Players:
	Game.Players.[i].HP = Game.Players[i].maxHP

which gives me error “Expected identifier as member”

Akuma | 2022-12-10 03:09

well… I see it now there was an extra dot there, was overthinking it, thanks

Akuma | 2022-12-10 04:01

Edit: I was talking nonsense for a moment, deleted that part :'D

As for your global variable, check if it really is in range of what you’d expect. You can set a breakpoint in your code by clicking to the left of that line. Then let the game run, and it will pause upon reaching that line. You can then inspect what variables hold at that moment of time.

aXu_AP | 2022-12-10 08:23