Hi,
This is a script I've created to simplify the usage of your games for the user. It does automatic object and hotspot interactions with the objects in a room. It also shortens the code you have to use for the events of the objects. When installed, you have a new class called OI, that you can call.
The following code can be used:
//Simple look code
function oCharacterSelector_Look()
{
OI.LookObject(oCharacterSelector, "It looks like a globe. I wonder if I can use it.");
}
//Simple interaction code
function oCharacterSelector_Interact()
{
OI.UseObject(oCharacterSelector, "I picked up the globe and added it to my inventory",true, iCharacterSelector,false);
}
Set WalkWhenLooking to true, to automatically walk to an object when you look at it.
Set WalkWhenUsing to true, to automatically walk to an object when you look at it.
LookObject() walks towards an object and says the text
UseOnbject() walks towards the object and uses it.
Set AutoView to true, to automatically call the "view" event of the object when the user walks to it.
Set AutoUse to true, to automatically call the "use" event of the object when the user walks to it.
Note! To enable the automatic view and use, make sure you add the following line to your GlobalScript.asc:
else if (button == eMouseLeft) {
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
//Hook the automatic view method here
OI.ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
Download the ObjectInteractions script (https://dl.dropboxusercontent.com/u/20918686/ags/ObjectInteractions.scm)
Update 0.2:
I've updated the code to also support hotspots and added some checks to check first if there is an interaction defined. If not, it just ignores the interaction. It also supports now the usage of multiple characters and share inventiry items between them. But then make sure you have installed: http://www.adventuregamestudio.co.uk/forums/index.php?topic=51969.msg636510747#msg636510747
If you don't have or don't need it, just simple comment out these lines:
CS.AddSharedInventory(aItemToAdd);
nice one.
Thanks a lot nims. great job.
I've updated the code to also support hotspots and added some checks to check first if there is an interaction defined. If not, it just ignores the interaction. It also supports now the usage of multiple characters and share inventiry items between them. But then make sure you have installed: http://www.adventuregamestudio.co.uk/forums/index.php?topic=51969.msg636510747#msg636510747
If you don't have or don't need it, just simple comment out these lines:
CS.AddSharedInventory(aItemToAdd);