0 votes
by (190 points)
Hi, i'm trying to add a random damage by a source that refresh his randomness every time the player takes damage by this source i tried something like this:

(set: $fullhealth to 10)
(set: $health to $fullhealth)
(set: $damage to (either: "2", "3", "4"))
(set: $health to it - $damage)

$fullhealth is yur life
$damage you took damage

|links>[{
    (link: "fight")[
        (replace: ?links)[$health this is your life now]
        
    
}]

but it gives me error.

some ideas?
Thanks

1 Answer

+1 vote
by (159k points)

Please use the Insert Code Snippet button when adding code examples to your questions / comments, it makes them easier to find and read.

The first two lines of your example are assigning Number values to the $fullhealth and $health variables

(set: $fullhealth to 10)
(set: $health to $fullhealth)

The 3rd line is assigning a (random) String value to the $damage variable.

(set: $damage to (either: "2", "3", "4"))

The 4th line is trying to delete the String value from the Number value, which results in an error becayse the data-type of the two values is different.

(set: $health to it - $damage)


The solution is to change the String values within the 3rd line to be Numbers instead.

(set: $damage to (either: 2, 3, 4))

 

...