/usr/share/doc/sludge/ExampleProjects/VerbCoin/iface/talk.slu is in sludge-doc 2.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # At last... interactive conversations!
# Use "addSpeechChoice (spokenLine, returnValue)" to build up a set of
# conversation choices... the "spokenLine" parameter is visible on the
# screen, and the "returnValue" parameter is sent back from getSpeechChoice
# should the player choose that line.
# The "character" parameter in "getSpeechChoice (character)" determines
# who says the line which was chosen. If you pass in NULL then nobody
# speaks and getSpeechChoice ends immediately.
# See the new version of the outside/room.slu file for examples.
var speechChoices = newStack ();
var gotSpeechClick;
sub addSpeechChoice (a, b) {
# Is the stack of choices empty? If so, change the status bar
# settings and mouse icon...
if (! speechChoices) {
clearStatus ();
alignStatus (LEFT);
setStatusColour (255, 200, 55);
setCursor (anim ('iface/mouse.duc', 0))
}
# Add a new status bar and set the text...
addStatus ();
statusText (a);
# Remember the return values by adding them to a stack...
pushToStack (speechChoices, b);
}
sub getSpeechChoice (character) {
hideCharacter (inventoryIcon);
onLeftMouse (speechClick);
loop {
var selected = (537 - getMouseY ()) / 32 - 1;
gotSpeechClick = FALSE;
lightStatus (selected - 1);
# Give the player a chance to click the mouse button...
pause (1);
# ...and check whether they did
if (gotSpeechClick) {
# Make sure they clicked a line of text
if (selected >= 1 && selected <= stackSize (speechChoices)) {
# Find and store the text to be spoken...
while (selected > 1) {
selected --;
removeLastStatus ();
popFromStack (speechChoices);
}
var theValue = getStatusText ();
# Remove all the remaining status bars and get rid of the mouse handler
clearStatus ();
onLeftMouse ();
# We'd better put the status bar set-up back to
# how it was before...
addStatus ();
alignStatus (CENTRE);
setStatusColour (255, 255, 255);
lightStatus (-1);
# Bring back the inventory icon
showCharacter (inventoryIcon);
# And turn the mouse back into the busy icon...
setCursor (anim ('iface/mouse.duc', 1));
# Only say the line if character != NULL
if (character) say (character, theValue);
# Remember the value we want to return and then
# empty the stack
theValue = popFromStack (speechChoices);
speechChoices = newStack ();
# Finally we return the value the player chose
return theValue;
}
}
}
}
sub speechClick () {
gotSpeechClick = TRUE;
}
|