Mar-22-2021, 04:57 PM
Hi guys,
Just started with python and is trying to create a dice generator for a specific RPG-game.
I am trying to get an answer back from a function that calculated the outcome.
But I cant get it to work.
Getting the follwing error:
It is the RETURN, RESULT in the end of eah code snippets that do not work, and generate the issue.
This is the code:
Main.py
Please advise!
Just started with python and is trying to create a dice generator for a specific RPG-game.
I am trying to get an answer back from a function that calculated the outcome.
But I cant get it to work.
Getting the follwing error:
Error:Traceback (most recent call last):
File "/Users/andreas.freij/PycharmProjects/Forbidden Lands Dice Generator/main.py", line 27, in <module>
result = roll_dice()
TypeError: roll_dice() missing 5 required positional arguments: 'number_of_roll', 'dice_type', 'sides', 'result_list', and 'damage'
Process finished with exit code 1
I guess it should be possible to feed a function with some values, and get some other variable back. Right?It is the RETURN, RESULT in the end of eah code snippets that do not work, and generate the issue.
This is the code:
Main.py
from dice import roll_dice if number_of_Base != "0": roll_dice(int(number_of_Base), Base.dice_type, Base.sides,Base.result_list, Base.damage) result = roll_dice()dice.py
def roll_dice(number_of_roll, dice_type, sides, result_list, damage): victory_points = 0 skulls = 0 import random for x in range(int(number_of_roll)): dice_outcome = random.randint(1,int(sides)) victory_points = victory_points + int(result_list[(dice_outcome)-1]) if dice_outcome == 1 and damage is True: skulls = skulls + 1 return victory_points,skullsI have also tried:
victory_points, skulls = roll_dice()But with the same result...
Please advise!