1
Technical forum / Placing items in a scene
« on: September 22, 2012, 10:41:11 AM »
Hello all,
I'm having issues with placing an inventory item in a scene. To give you some context, I have an inventory item (Some Dried Leaves) that need to be placed on a campfire (a regional entity in my scene). I'm using an entity file to do this currently, and the issues are:
Issue 1 - The entity originally did not appear when I set its active property to true (in the script below). I assumed this was because it was being "made active" behind the background layer, as the rest of the code worked. I'm not sure what I did, but now the entity appears, but now overlays all other entities including the actor. I only have 1 layer in my scene. I had originally tried the below code as a global variable in the game.script, but the entity would not appear at all, so I moved its declaration to the regional entity script (campfire.script). I can only assume this is what fixed it not appearing at all.
Issue 2 - The entity appears when the campfire code is executed, but it can then be seen in all other scenes in my game. I only want it to appear in one. How can this be done?
Please see a code snippit below to help:
In my campfire.script:
and here's the driedleaves.entity definition:
After the above, I want to place a chimney over the leaves once they have been set on fire. I assume the answers to the above will allow me to do this also.
I could be going about this the completely wrong way and there may be a better way of doing this. Any help would be greatly received.
Squin
I'm having issues with placing an inventory item in a scene. To give you some context, I have an inventory item (Some Dried Leaves) that need to be placed on a campfire (a regional entity in my scene). I'm using an entity file to do this currently, and the issues are:
Issue 1 - The entity originally did not appear when I set its active property to true (in the script below). I assumed this was because it was being "made active" behind the background layer, as the rest of the code worked. I'm not sure what I did, but now the entity appears, but now overlays all other entities including the actor. I only have 1 layer in my scene. I had originally tried the below code as a global variable in the game.script, but the entity would not appear at all, so I moved its declaration to the regional entity script (campfire.script). I can only assume this is what fixed it not appearing at all.
Issue 2 - The entity appears when the campfire code is executed, but it can then be seen in all other scenes in my game. I only want it to appear in one. How can this be done?
Please see a code snippit below to help:
In my campfire.script:
Code: WME Script
- //declare what DriedLeavesEntity is
- //make it inactive until we need it
- DriedLeavesEntity.Active = false;
- //when dried leaves are used on the campfire
- on "leaves"
- {
- //go to the campfire
- //unselect the leaves item as we are using them
- //drop the item. We do not want to delete as the fire will only burn for a certain amount of time.
- //If the player has not applied the chimney before the fire burns out, we need to be able to pick up the leaves again.
- //whether the leaves can be picked up again are controlled by a separate global variable.
- //show the leaves on the campfire
- DriedLeavesEntity.Active = true;
- }
and here's the driedleaves.entity definition:
Code: [Select]
ENTITY
{
NAME="driedleaves"
CAPTION="Dried Leaves"
ACTIVE=TRUE
X=667
Y=385
SCALABLE=FALSE
INTERACTIVE=TRUE
COLORABLE=FALSE
SPRITE="entities\driedleaves\sprites\driedleaves.sprite"
SCRIPT="entities\driedleaves\driedleaves.script"
FONT = "fonts\outline_red.font"
}
After the above, I want to place a chimney over the leaves once they have been set on fire. I assume the answers to the above will allow me to do this also.
I could be going about this the completely wrong way and there may be a better way of doing this. Any help would be greatly received.
Squin