![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Syl |
Greets!
I’m tinkering to get random enconters through the roll_a_dice function, and i managed that so far:
extends Node2D
func _ready():
randomize()
func _physics_process(_delta):
if Input.is_action_pressed("ui_right"):
_on_action_pressed()
func _on_action_pressed():
roll_a_dice(1, 100)
func roll_a_dice(minimum, maximum):
var roll = randi() % (maximum-minimum+1) + minimum
print(roll)
if roll <= 50:
print("ok")
if roll > 50 and roll <= 75:
print("nope")
if roll > 75 and roll < 100:
print("okokok")
It works almost fine, but for the fact that i got unlimited serie of printed roll and result in the output. What should i add or remove to get only one?
Cheers!