(Solved!) A NEW Problem with Key_Interact functions

Started by limeyman1992, Sat 26/06/2010 02:08:04

Previous topic - Next topic

limeyman1992

Okay, after fixing my last problem I encountered a new one. When I attempted to play the game, it would not let me pick up the key. Here's the script again if you can understand why it's not working:

function okey_Interact()
{
okey.Visible = false;
player.AddInventory(iKey);
Display("I picked up the key. I hope it fits the cuffs. If not then that's just teasing...");
}

And here's the warning message it gave me after the game wouldn't let me pick up:
Error: prepare_script:error -18 (No such function in script) trying to run 'Key_interact' (Room 1)

Calin Leafshade

remember you have to create a new inventory item in the list on the right hand side in the project tree..

also its a good idea to get into using naming conventions.

so the object 'key' might be called oKey
and the inventory item key might be iKey.

Dualnames

Code: ags

function key_Interact(){
key.Visible = false;
player.AddInventory(ikey);                //<---- This is the line the AGS had a problem with
Display("I picked up the key. I hope it fits the cuffs. If not that's just teasing...");
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

limeyman1992

I tried using okey and ikey but that didn't work. I'm going to recheck the inventory section of the tutorial to make sure I've not missed anything

Dualnames

Quote from: limeyman1992 on Sat 26/06/2010 11:21:41
I tried using okey and ikey but that didn't work. I'm going to recheck the inventory section of the tutorial to make sure I've not missed anything

The object must be given a script name!
And the inventory has already a script name, starting with i (I assumed its iKey)

Code: ags

function key_Interact(){
object[0].Visible = false;
player.AddInventory(inventory[1]);                //<---- This is the line the AGS had a problem with
Display("I picked up the key. I hope it fits the cuffs. If not that's just teasing...");
}


This may work just by referencing ID numbers instead of script names.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Vince Twelve

Actually, it looks like the problem is that the function is incorrectly linked to the item's interactions.

This function is called okey_Interact() but it's looking for Key_interact().  You can either rename this function (make sure to pay attention to capitals.  Capital 'K', lower case 'i') or you can go into the room editor, switch to object editing, choose the key, then press the lightning button.  Look at the function named here under interact and make sure it matches the one in your script.  If you press the ... button, it should go straight to it.

limeyman1992

Thanks everyone for helping, I've fixed it now ^_^

SMF spam blocked by CleanTalk