Thought I more-or-less did that, but in not a quite so elegant way.
(Please correct me if I’m wrong, because I’d really like learn to to do this properly.)
What I’d really like to get working, eventually, is a way to trigger an Inform7 event based on a change of button state.
Now that is something that I expect is rather difficult.
Here is the script code:
[code]upImage = new Image();
upImage.src = “buyit15u.jpg”;
downImage = new Image();
downImage.src = “buyit15d.jpg”
normalImage = new Image();
normalImage.src = “buyit15.jpg”;
function insertButtonCode()
{
$(’.buttonCode’).append(’’);
};
function removeButtonCode()
{
$(’.buttonCode’).remove();
};
function changeImage()
{
document.images[“jsbutton”].src= upImage.src;
return true;
}
function changeImageBack()
{
document.images[“jsbutton”].src = normalImage.src;
return true;
}
function handleMDown()
{
document.images[“jsbutton”].src = downImage.src;
return true;
}
function handleMUp()
{
changeImage();
return true;
}
[/code]
Here is the Inform7 code:
[code]“Buttons2” by Gary
Include Vorple by Juhana Leinonen.
Release along with the “Vorple” interpreter.
Release along with JavaScript “Button.js”.
Release along with a file of “buyit15u” called “buyit15u.jpg”.
Release along with a file of “buyit15d” called “buyit15d.jpg”.
Release along with a file of “buyit15” called “buyit15.jpg”.
Placing a button is an action out of world.
Understand “place” as Placing a button.
Carry out placing a button (this is the carry out placing a button rule):
if Vorple is available:
execute JavaScript command “removeButtonCode()”; [Erase any previous button(s)]
open HTML tag “div” called “buttonCode”; [Start the tag to contain the button]
say "This is a button: "; [‘Introduce the button’]
close HTML tag; [End the tag to contain the button]
execute JavaScript command “insertButtonCode()”; [Place the button]
mark the current action “normal”; [Make sure it appears in the turn area]
otherwise:
say “[bold type]Buttons are not possible without VORPLE[roman type]”;
Erasing a button is an action out of world.
Understand “erase” as erasing a button.
Carry out erasing a button (this is the carry out erasing a button rule):
if Vorple is available:
execute JavaScript command “removeButtonCode()”; [Erase any previous button(s)]
otherwise:
say “[bold type]Buttons are not possible without VORPLE[roman type]”.
Example Location is a room.
[/code]