Twine Version: 2.3.14 Sugarcube
Hi, I’m experimenting with a feature in my game that offers the player a link to share their game score on social media. Something like: “I completed The Princess of Vestria, here are my ratings:” (and then a list of different trait scores for wisdom, compassion, charisma etc.)
I posed this to Chat GPT last night, and it came up with something… that doesn’t work, and I have no idea if it’s even close Here’s what Chat GPT gave me:
<ul id="score-list">
<li>Ruler success:  4/5</li>
<li>Magic:      $magickrating/5</li>
<li>Ruthlessness:   $ruthlessnessrating/5</li>
<li>Wisdom:     $wisdomrating/5</li>
<li>Diplomacy:    $diplomacyrating/5</li>
<li>Compassion:   $compassionrating/5</li>
<li>Charisma:     $herorating/5</li>
</ul>
<a id="share-button" href="#" onclick="shareScores(); return false;">Share your score</a>
(the &emsp indents are my own clumsy formatting, not Chat GPT’s fault)
And then in JavaScript:
// Initialize variables with values from Twine passage
var sv = State.variables;
var stabilityindex = sv.stabilityindex;
var magickrating = sv.magickrating;
var ruthlessnessrating = sv.ruthlessnessrating;
var wisdomrating = sv.wisdomrating;
var diplomacyrating = sv.diplomacyrating;
var compassionrating = sv.compassionrating;
var herorating = sv.herorating;
// Function to open Twitter share link
function shareScores() {
var tweetURL = "https://twitter.com/intent/tweet?url=" + encodeURIComponent("https://k-paulo.itch.io/the-princess-of-vestria-beta") + "&text=" + encodeURIComponent("I completed The Princess of Vestria, here are my ratings: Ruler success: " + stabilityindex + "/5 Magic: " + magickrating + "/5 Ruthlessness: " + ruthlessnessrating + "/5 Wisdom: " + wisdomrating + "/5 Diplomacy: " + diplomacyrating + "/5 Compassion: " + compassionrating + "/5 Charisma: " + herorating + "/5 #ThePrincessOfVestria");
window.open(tweetURL, "_blank");
}
There was a bit of back and forth where I told Chat GPT what error messages I was getting and it gave suggestions… In the end I felt we were just going around in circles though. The error message I get now testing the game is that “shareScores is not defined”
Can anyone help?