I'm wrote my own scripts doing the same thing.
First is a scene.script, here it is:
#include "scripts\base.inc"
//temporary variables
var itemname;
var itemcaption;
var itemsprite;
var itemtodrop;
var newent;
//item temporary store
global Xtosave;
global Ytosave;
global tulipXtosave;
global tulipYtosave;
//function that drop objects
function ObjectDrop(itemname, itemcaption, itemsprite)
{
//naturally, this checks if the item can "walk" into position :)
if (Scene.IsWalkableAt(Scene.MouseX, Scene.MouseY))
{
//actor walks somewhere around dropping object
actor.GoTo(Scene.MouseX+47, Scene.MouseY+47);
Sleep(400);
actor.TurnTo(DI_UPLEFT);
Sleep(400);
//turning off the interaction
Game.Interactive=false;
//setting up the objects
itemtodrop=actor.GetItem(itemname);
newent=Scene.CreateEntity(itemname);
//turning visibility off
newent.Active=false;
//setting parameters up
newent.Interactive=true;
newent.Scalable=true;
newent.Colorable=true;
newent.Caption=itemcaption;
newent.WalkToX=actor.X;
newent.WalkToY=actor.Y;
newent.WalkToDirection=actor.Direction;
newent.AttachScript("scripts\object_take.script");
//fix 1: saving position
Xtosave=actor.X-47;
Ytosave=actor.Y-47;
//setting last parameters up
newent.SkipTo(Xtosave, Ytosave);
newent.SetSprite(itemsprite);
if((itemtodrop.DisplayAmount==true)&&(itemtodrop.Amount>1))
{
//decreasing amount of the item by 1
itemtodrop.Amount=itemtodrop.Amount-1;
newent.Active=true;
}
else
{
//deleting item
itemtodrop.Amount=0;
newent.Active=true;
Game.SelectedItem=null;
Game.Interactive=true;
actor.DropItem(itemname);
}
Game.Interactive=true;
}
}
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
// when the scene is left-clicked, just send the actor to the specified point
actor.GoTo(Scene.MouseX, Scene.MouseY);
}
on "tulip"
{
//calling function that drop objects
ObjectDrop("tulip", "Tulip", "items\tulip.sprite");
//adding object coordinates into array
tulipXtosave.Push(Xtosave);
tulipYtosave.Push(Ytosave);
}
Second is a object_take.script, here it is:
#include "scripts\base.inc"
var itemtopick;
global tulipXtosave;
global tulipYtosave;
on "LeftClick"
{
//walk to previously setted coordinates
actor.GoToObject(this);
//turning off the lig... er, interaction
Game.Interactive=false;
//acquire, i.e. get item (even if it is already taken)
actor.TakeItem(this.Name);
//getting the object of the item
itemtopick=actor.GetItem(this.Name);
//increasing amount of the item by 1
itemtopick.Amount=itemtopick.Amount+1;
//deleting coordinates of this item
//(or maybe other identical, but that doesn't matter)
switch(this.Name)
{
case "tulip":
tulipXtosave.Pop();
tulipYtosave.Pop();
break;
case "default":
actor.Talk("An error happened. The item is not deleted correctly.");
actor.Talk("Look into object_take.script.");
break;
}
//turning on the interaction
Game.Interactive=true;
//entity (sprite container) should be deleted after all other things
Scene.DeleteEntity(this);
}
on "default-use"
{
Sleep(1);
}
Part of game.script:
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
// what did we click?
var ActObj = Game.ActiveObject;
var Item = Game.SelectedItem;
if(ActObj!=null)
{
// clicking an inventory item (no item, item under cursor)
if(ActObj.Type=="item" && Game.SelectedItem==null)
{
Game.SelectedItem = ActObj;
}
// using an inventory item on another object (object and item exist)
else if(Item != null && Item!=ActObj)
{
if(ActObj.CanHandleEvent(Item.Name)) ActObj.ApplyEvent(Item.Name);
else if(Item.CanHandleEvent("default-use")) Item.ApplyEvent("default-use");
else if(ActObj.CanHandleEvent("default-use")) ActObj.ApplyEvent("default-use");
else actor.Talk("I can't use these things together.");
}
// just a simple click (object exist, item is not)
else ActObj.ApplyEvent("LeftClick");
}
else if(Scene.CanHandleEvent(Item.Name)) Scene.ApplyEvent(Item.Name);
else
{ // else propagate the LeftClick event to a scene (object and item not exist)
Scene.ApplyEvent("LeftClick");
}
}
In items.items:
ITEM
{
CURSOR_COMBINED = FALSE
CAPTION = "Tulip"
NAME = "tulip"
IMAGE = "items\tulip.png"
IMAGE_HOVER = "items\tulip.png"
CURSOR = "items\tulip.sprite"
FONT = "fonts\cmbr16.font"
SCRIPT = "items\tulip.script"
DISPLAY_AMOUNT = TRUE
AMOUNT_ALIGN = "right"
}
Part of scene_init.script:
global tulipXInPOTION;
global tulipYInPOTION;
if (tulipXInPOTION==null) tulipXInPOTION=new Array();
if (tulipYInPOTION==null) tulipYInPOTION=new Array();
global tulipXtosave=tulipXInPOTION;
global tulipYtosave=tulipYInPOTION;
Exit region script:
#include "scripts\base.inc"
on "ActorEntry"
{
//getting temporal variables
global tulipXtosave;
global tulipYtosave;
//setting constant variables as temporal
global tulipXInPOTION=tulipXtosave;
global tulipYInPOTION=tulipYtosave;
Game.ChangeScene("scenes\Room\Room.scene");
}
And include file that restores items (#include "scripts\restore_items.inc" should be written in every scene_init.script)
var newent;
var am;
var itemname, itemcaption, itemsprite, itemarrayX, itemarrayY;
function ObjectPlace(itemname, itemcaption, itemsprite, itemarrayX, itemarrayY)
{
for(am=0;am<itemarrayX.Length;am=am+1)
{
//Re-creating entity
newent=Scene.CreateEntity(itemname);
//Turning visibility off
newent.Active=false;
//Setting up again
newent.Interactive=true;
newent.Scalable=true;
newent.Colorable=true;
newent.Caption=itemcaption;
newent.AttachScript("scripts\object_take.script");
newent.SkipTo(itemarrayX[am], itemarrayY[am]);
newent.WalkToX=newent.X+47;
newent.WalkToY=newent.Y+47;
newent.WalkToDirection=DI_UPLEFT;
newent.SetSprite(itemsprite);
//Turning visibility on
newent.Active=true;
}
}
ObjectPlace("tulip", "Tulip", "items\tulip.sprite", tulipXtosave, tulipYtosave);