Twine Version: 2.3.13
Story Format: SugarCube 2.34.1
Browser: Mozilla Firefox 78.11.0esr (64 bits)
Good morning,
I’m exploring SugarCube tools, and I’ve tried to use a template.
First question: is there a way to store templates the same way we store widgets? I’ve tried to add a ‘templates’ tag to a passage but it didn’t achieve the hoped result. I’ve not been able to find anything about this with an internet search.
At https://www.motoslave.net/sugarcube/2/docs/#template-api there’s a quick description of some template functions, but it lacks a description of what is a template and how it works exactly in the first place.
Second question: what does mean the following sentence error? How can I fix it?
Error: <>: bad evaluation: cannot clobber existing template ?Couleur
As English is not my native language, I’m in trouble to understand the ‘clobber’ meaning. Thefreedictionnary gives:
tr.v. clob·bered , clob·ber·ing , clob·bers Slang
1. To strike violently and repeatedly; batter or maul.
2. To defeat decisively.
3. To criticize harshly.
Unfortunately none of the above meanings makes sense to me relatively to a coding feature.
As a matter of fact meaning is quite… meaningless if an internet search gives way to fix it. Alas I had no luck again.
So, to the basics: how did I hit this error?
Here’s the code.
<<script>>Template.add('Couleur', function(){return either("blanc","bleu","jaune","noir","rouge","vert");})<</script>>
Gaspard est habillé d'un T-shirt ?Couleur.
At this point it looks like it’s working well, one of the colour is randomly selected. If I refresh the page one is selected again, it may be the very same or another one, as intended.
The trouble comes with the ‘Go backwarkd within the game history’ button. Something happens or does not happen and the ‘Error message’ listed above appears. What is even more puzzling is that the function still selects a colour. So, basically, it’s an error message about something that otherwise looks to work well.
Could someone here please help me with one or both questions?