Help with Scripting: "Visible is not a public member of Inv.."

Started by ?DaltonSezHi!, Thu 30/06/2011 00:01:59

Previous topic - Next topic

?DaltonSezHi!

Yeah, one problem to another, now, when I try to test my game, it says exactly the title of the post. Here's the script I wrote down.


function iKey_Interact()
{
player.Walk(152, 151, eBlock);
iKey.Visible = false;
player.AddInventory(iKey);
}

Also, thats almost EXACTLY how it was in the tutorial.

monkey0506

Where was this example "almost exactly" written in the manual?

Just like the error message says, "Visible" is not a property of "InventoryItem". InventoryItems are shown based on a given Character's InventoryQuantity for the given item. If the InvWindow's CharacterToUse property is set to a given Character, and that Character has at least one of a given InventoryItem, then that item will be shown in this InvWindow.

If you don't want it to show up then you have to either script your own InvWindow, use another Character as a dummy for the displayable inventory, or some other method. In short, if the player has the item, it will be shown in his inventory.

?DaltonSezHi!

It was in the tutorial, when you go to the main page and click tutorial. It was in the Animation and Cutscene part.

So the turtorial lies? D:

EDIT: I found the Problem, let's hope I dont encounter much more.

Khris

Edit: No, it doesn't, you didn't follow it exactly.  >:(

It's in Getting Started with AGS - Part 7.

The problem is that according to the tutorial, you're supposed to create a room object named oKey.
And that's what gets interacted with and that's also what's supposed to be turned invisible after you pick it up.

Instead of creating the function pertaining to the event "interact with object", in this case the room object oKey, you have created the function linked to the event "interact with inventory item". (One of the problems here is that how would the player interact with an item they only get after interacting with it...?)

The idea is that there's a room object called oKey and interacting with it i.e. picking it up turns the room's object's visibility off while the inventory item iKey is added to the player's inventory.

To better understand this it is crucial to realize that the only link between a room object and an inventory item is in the designer's mind. They both represent the same game world object, but in AGS, the two are entirely separate.

monkey0506

Had you actually followed the instructions given in that section of the manual, you would have recognized that oKey (not iKey!!) is a room Object, not an InventoryItem. There is an Object.Visible, but no InventoryItem.Visible.

Although it's not enforced, the convention for programming in AGS, when dealing with the complex built-in data types like Object or InventoryItem is to prefix the names of things with something to indicate their type. For example:
oKey: The room Object representing a key.
iKey: An InventoryItem representing a key.
cEgo: A Character, named Ego (this doesn't necessarily reflect the Character.Name, this is just the script name).
gPanel: A GUI called Panel.
lblStatus: A Label called Status.
invWindow: An InvWindow called Window.
As you can see, this helps you to quickly identify what type of thing something is based on its script name. Again you don't have to do this, but it can help in identifying things (a lot!!). Also, you might notice that we gave the Label and the InvWindow three-letter prefixes instead of just one-letter. This is also somewhat by convention to prevent confusion between Labels and ListBoxes, or InvWindows and InventoryItems.

Edit: Khris ninja'd me, but he's right. The tutorial doesn't lie, you're just doing it wrong. :P

Khris

Quote from: ?DaltonSezHi! on Thu 30/06/2011 00:11:55
EDIT: I found the Problem, let's hope I dont encounter much more.

Just follow the tutorial almost EXACTLY, and you shouldn't ;)

mystazsea

Yes be careful with your signature usage..it can lead to trouble..
quote
"I reject your reality and substitute my own!"



if (You don't know what you are doing) == true
& (You don't follow instructions/Tutorials Properly) == true

then
{
(it's most likely to be your fault )= true;
}

Substituting your own reality doesn't necessarily guarantee automatic success in all cases...

:)


Trousers on then put on shoes...

SMF spam blocked by CleanTalk