in reply to How can you save some data?
is that you re-initialise the character's hit points to 400 every time you call it. The first line sets their hit points to 400, and then the next line subtracts a random number from it. Why do you need this in a function at all? Isn't it easier to just dosub Char{ my $char=400; my $hp= $char - int(rand(20)); print $hp ; }
instead of calling a function?$hp= $hp-int(rand(20));
|
|---|