ok this is in the globalscript and no problems here, but AFTER all that scripting i want to be able to use other stuff on the character...on the next screen for example he gets a shovel and if i use that on Ego i want him to say something like "No i can't use that on myself" what should i script? the else if doesn't seem to work...and i'm new to scripting so a little help would be very nice hehe....so...I need help to be able to add more stuff that can be used on my character :)
function cEgo_UseInv()
{
if(player.ActiveInventory == ibook){
cEgo.LockView(4);
cEgo.Animate(3, 1, 0, eBlock, eForwards);
cEgo.UnlockView();
cEgo.FaceLocation(cEgo.x -10, cEgo.y);
Display("Let's see what we have here");
cEgo.LockView(4);
cEgo.Animate(3, 1, 0, eBlock, eForwards);
cEgo.UnlockView();
cEgo.FaceLocation(cEgo.x -10, cEgo.y);
Display ("Hmm...I recognise Grampa's handwriting. He actually managed to translate this");
cEgo.LockView(4);
cEgo.Animate(3, 1, 0, eBlock, eForwards);
cEgo.UnlockView();
cEgo.FaceLocation(cEgo.x, cEgo.y +10);
Display ("This spell opens a gate to another world. I've never spoken these words out loud");
Display ("Who knows what might happen? Whoever's reading this...Be extremely careful");
cEgo.LockView(4);
cEgo.Animate(3, 1, 0, eBlock, eForwards);
cEgo.UnlockView();
cEgo.FaceLocation(cEgo.x, cEgo.y +10);
Display ("Ah get real gramps...don't say you actually believed in this?");
cEgo.Walk(282, 401, eBlock);
cEgo.FaceLocation(cEgo.x, cEgo.y +10);
Display ("Here goes nothing");
Display ("in circulus vitiosus, abiit, excessit, evasit, erupit");
cEgo.Transparency = 100;
object[3].Visible = true;
PlaySound (4);
object[3].SetView(5, 3);
object[3].Animate(3, 1);
object[3].Visible = false;
Wait (40);
cEgo.LoseInventory(ibook);
cEgo.LoseInventory(iKey);
player.ChangeRoom(2, 200, 580);
}
Hello! Just keep on adding in 'if' statements!
function cEgo_UseInv()
{
if(player.ActiveInventory == ibook)
{
cEgo.Say("You used the book!");
}
if(player.ActiveInventory == ishovel)
{
cEgo.Say("You used the shovel!");
}
if(player.ActiveInventory == iunusualTrousers)
{
cEgo.Say("You used the unusual trousers!");
}
if(player.ActiveInventory == iwhateverYouWant)
{
// whatever, and so on!
}
}
Ah yeah i tried that before and didn't get it to work...probably missed something. works now. Thanks for the quick reply :)
You're missing a close bracket } on your original post, that might have something to do with it...
Related topic: To save space in my global script, I created a function called c_UseInv in a module script. I then passed Character.GetAtScreenXY as the parameter, and put all my interactions in that script.
You could do a similar thing, like this:
//global script
import playerUseInv(InventoryItem *item); //since you'll only use this function here, no need to put the import in the module header
function cEgo_UseInv() {
playerUseInv(player.ActiveInventory);
}
//module script
function playerUseInv(InventoryItem *item){
if(player.ActiveInventory == ibook)
{
cEgo.Say("You used the book!");
}
if(player.ActiveInventory == ishovel)
{
cEgo.Say("You used the shovel!");
}
if(player.ActiveInventory == iunusualTrousers)
{
cEgo.Say("You used the unusual trousers!");
}
if(player.ActiveInventory == iwhateverYouWant)
{
// whatever, and so on!
}
}
~Trent
PS-I stole a piece zombiecow's code :)