MikeOmega wrote:At the start of the test game, the player already has two items in his inventory, a helmet and a sword. The helmet has its own unique attribute of "armor" which has a integer value of 10, and the sword has its own unique attribute of "power" with an integer value of 10. My first stumbling block was having the command check for both the separate objects in the player's inventory. The player command is "Combine #object# and #object# . I attempted an If-Then script which would check if the player has two different objects by their name stated in the command. I have a temporary fix by creating my own expression "If Got(object) and Got(object)" and the "then" statement I chose from the dropdown was to create an object I called "strangematter". How do I set the new object "strangematter" to have the attributes of both the objects the uses in the commands, the power and armor integer values? And how do I set this created object's name or alias to that which combines the names of the objects specified in the command?
Maybe I'm missing something here, but why would the player be combining the helmet and sword? And I'm a little fuzzy on what you're actually trying to accomplish here. If you could give some more detail it would be helpful.
MikeOmega wrote:Another command I am having trouble with is an equip command, which allows for a player to equip an item in his inventory, which then adds the value of certain attributes of the item to player status attributes. Such as, if a player were to equip a helmet mentioned earlier, the integer value of the helmet's armor attribute would be added to the player's armor status attribute. Now the problem is, you can use the equip command multiple times and it just keeps stacking the values regardless of whether or not an object is already equipped. Is there a way to make the equip command only work if the object is not already equipped?
This one's actually fairly easy, and you've pretty much got it right, you're just overlooking something simple. All you need to do is add an attribute to the object, let's call it "equipped". Then, you just need to change your code to alter the attribute when the item is equipped/unequipped. So, if the player types "equip helmet" it will change the value of helmet.equipped to "1". The other change you need to make to the equip command is to have it check the "equipped" value of the object. If the value is "1" or "true" or whatever you set it to, have it display a message saying the item is already equipped. Don't forget to change the value back to "0" or "false" when the item is unequipped as well.
Using something similar to this, you could also pretty easily make a check to ensure the player can't equip mutliple types of the same item, like multiple helmets, for example.
MikeOmega wrote:The final command I can't seem to grasp is an attack command that, like the others, works generally for multiple objects. I have a monster simply called "monster" and when the player uses the command "attack #object#" I would like for damage to be done to the object specified in user's command via subtracting the player's strength (player.strength) from the object's health (object.health). This seems to work, but then I want the attack command to check if the object attacked has health less than or equal to zero and if so, to display a message saying that the creature is dead. If there is more than one item in the room, the script seems to have trouble recognizing which object I want the command to reference. How do I fix this?
I have uploaded the test game with the commands available. Any help you all could offer would be greatly appreciated!
This is probably got something to do with how you've got the object referenced in the command. I'll download your test file now and have a look and see if I can figure out what's wrong.
EDIT:I took a look at your file and made some small changes. Firstly, I changed the equip/unequip code with the changes I mentioned above. Looks like you were even closer to the right solution than you indicated, because you already had an equipped attribute set on the objects.
Secondly, I altered the attack command slightly. First of all, I used a new variable. It's not a great idea to leave the variable as just "object" because that can lead to problems, so I called it "object_monster". Important thing to remember is that the variable always has to start with what kind of thing it's referencing, so if it's an object, it has to start with "object" or it won't work. I also edited the damage check to "if (object_monster.health = 0)" to "if (object_monster.health <= 0)". Otherwise the command won't work properly unless the monster's health is exactly 0. This way it will work if it slips into the negatives as well.
Thirdly, I altered the variable names for the combine command. As I stated before, it's a good programming practice to not do that because it can cause problems, so I altered it to "object_1" and "object_2". And that could explain the problems you were having getting it to work from before.
I haven't tested any of this so it's possible it might not work, but it should.