Alright, I've got some card locks in my game and I'd like to be able to have the game post a message if the player uses the wrong keycard. But I'm completely against having to go back in and change the room script every time I add a different keycard object.
Is it possible to declare an array of objects in AGS? I've noticed that "object" isn't a blue keyword, and that the help file does NOT define object as a data type. Is there a way around this limitation, and if not, is it in AGS 2.8?
You could declare an InventoryItem array like this:
InventoryItem*i[10];
However, you won't need this.
Add a custom int property (default -1) holding the InventoryItem.ID of the right keycard for every door.
In the "use inv on door" script, use
// your doors are objects
Object*x=Object.GetAtScreenXY(mouse.x, mouse.y);
if (x==null) return;
// your doors are hotspots
Hotspot*x=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
if (h==hotspot[0]) return;
if (player.ActiveInventory.ID==x.GetProperty("keycard")) {
// open door, etc.
}
else player.Say("It won't work on this door.");
Edit: code corrected, thanks monkey
That code looks awfully different than the code I'm using. Is that AGS 2.8?
I'm afraid I have caused some confusion in my first post. I'm actually using AGS 2.7. My reference to AGS 2.8 was simply me wondering whether it would be possible to do such a thing in AGS 2.8.
That code would work in AGS 2.7 or higher. Well...except that the functions are Object.GetAtScreenXY and Hotspot.GetAtScreenXY. If this code looks horribly different from your own, why not post what you have so we can see what you've tried. It's possible if you followed a scripting tutorial designed for older versions of AGS that you're simply using old-style coding.
Oh good golly gosh! </innocence>
I was expecting some array declarations in the code and Khris used some property stuff instead! I was looking at the code, scratching my head, trying to find the array. *Looks stupid now*.
Thanks for solving my problem Khris, sorry for the confusion.