I'm trying to work again with S on this inventory thing. Here is the general idea.
The player has X number of equipped item slots (3 in this case) and a large area where inventory items can be kept (bag or case). When the player goes around and touched an item it is added to the case. If the player then switches to inventory mode they will see all of the items they have touched in the bag. They then have the option to equip and unequip items. When they equip an item the icon for that item displays in the equipped slot.
Of course, this could also relate back to the player. If they have certain items equipped then they could have those actually spawned with them (like a knife vs sword) or a magic spell.
Ok, that is the main idea. I've attached a .cap with a really rough implementation that is just really bad and doesn't work well. It crashes unless I switch to inventory mode before having the player run over the item. I completely do not understand that crash. It also doesn't work if more than one item is in the family. I thought one of your example used just the object kinda like what I am doing here (even though the family is specified). I clearly do not understand S right now.
Also, unrelated to S do you know a way to "pick object by name". For example, if the global var # of equipped is 0 I would like the equipped0 panel to display using something like (object name = "equipped&global("equipped").
Here is the .cap:http://www.box.net/shared/g3sf71mjl2
Thanks for any feedback.[/quote:peznt919]
sorry for the slow reply
the most important thing to remember when dealing with objs and objtypes is to recognize and remember the differences
it's definitely a little strange at first, because in construct you normally never have to think of the differences. The idea of S is to give you some of the same abilities you have when making a plugin in c++.
so if you want to remember what "kind" of object, that's an object type
you can create and object of an objecttype, or select objects of an objecttype, or even check if an object is of an objecttype
if you want to remember an actual object, that's object
objects are things on the screen, that can be moved around, destroyed, have behaviors on them, etc.
when you put the objects in the array, then you destroyed the objects, the array was remembering objects that were no longer there. To avoid this, when destroying objects inside an array, use the delete object action. This allows you to destroy the object and delete it in one step
for in an inventory, however, where you don't want the object on the screen, you just want to remember what type of object it is, that's an objecttype. please try the example, and let me know if you have any more questions.
one of the things I hope to eventually add to 's' is a debugging feature, where instead of crashing, there can be an "on error" condition, and a "geterror" expression, so you can set a textbox to the error, and see why it's happening. should make it easier to learn, and to find mistakes. that's a little further down the line though.