Line 45-49, I am trying to make it do math, and then go to $output. I’ll put an example here of what is currently happening, and then what I am trying to achieve.
Current:
You are trying to convince a guard to let you into a restricted area.
Difficulty: 60
Skill: Charisma
undefined + undefined = undefined
Expected example:
You are trying to convince a guard to let you into a restricted area.
Difficulty: 60
Skill: Charisma
50 + 22 = 72
On line 47 there is also a more specific issue, according to the red line highlighting it. The text ai was used to generate something like “Skill: Charisma” earlier in the code. Then on line 47, it is getting rid of the "Skill: " so all that remains is “Charisma”. There was a variable set at line 11 which shows the value of “Charisma”.
Hopefully I explained this well enough. Thank you for your assistance everyone!
(Edit: Put a line break in the output, to more closely match the output from the program)
I was setting the
check.roll
to the difficulty that was generated. I guess it was not intended that way in which theroll
is separate from the difficulty. You can change the section on thedifficulty
:difficulty async onFinish(data) => // check.roll = Number(data.text.replace("Difficulty: ", "")) // comment this out outputEl.innerHTML += ai(skill)
I’ve updated the code I’ve linked.
Thank you! I could have been more clear about my code lol. I was trying to get the LLM to think of how difficult a task would be. Then the player would roll a d100, and add their skill, to see if they succeed.