Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Problem: DropItem or SceneNode-Saving  (Read 4532 times)

0 Members and 1 Guest are viewing this topic.

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Problem: DropItem or SceneNode-Saving
« on: November 11, 2010, 02:56:09 AM »

Hello everyone!

I seemingly have the typical problem where the scene entities related to an item get set back to their original place in the scene after I drop them.
Of course I searched for a way to solve it (here on the forum) and I found it: I added a line to my custom Take-function where the scene entity's relation to the item gets disconnected...
It worked!
But then I confronted a new part of the same problem:
When I take an object, leave the scene to fetch another item, come back to the first scene and then drop both items while making a new one out of them, the first item reappears!
But as I found out after some trials, the entities' disconnected relations are connected again when I enter a scene again.

* "Remember nodes states" in SceneEdit is flagged.
* I tried ".SaveState" on the scene entities to be taken as well as on the scene -- didn't change anything.

I beg for a hint since I have been trying on this for several days now! @_@
Logged

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Problem: DropItem or SceneNode-Saving
« Reply #1 on: November 11, 2010, 04:20:57 AM »

If you want the item to be gone permanently, you have to use Game.DeleteItem("yourItemName");

DropItem only kicks it out of the inventory and returns it for later use.

EDIT: You can also read that in the References: http://docs.dead-code.org/wme/inside_inventory.html under "Assigning inventory items to scene objects"
« Last Edit: November 11, 2010, 04:24:02 AM by Darky »
Logged

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Re: Problem: DropItem or SceneNode-Saving
« Reply #2 on: November 11, 2010, 07:10:16 AM »

Well, .DeleteItem was my first thought, but it caused the usual problems like either deleting the script or even kind of freezing the game.
To prevent this I also could set the .DeleteItem command to the end of the whole "combining item function", but that seems not possible for me when my playing character comments the action with Talking -- it would look very strange if the actor said something like "got it!", adds another paragraph of monologuous comment and then the change within the inventory would be seen... that would look awkwardly unnatural...
... so I decided to use the second workaround method with disconnecting the item relation. Primarily this would solve the problem when I use .DropItem, but when I use .DeleteItem the command still freezes the game. :/
Therefore it really seems to me I should achieve to keep the state of the changed scene entities when reentering the scene -- which does not work properly yet.

EDIT: Also I have to delete 2 items in one action -- so putting the .DeleteItem cmmandS at the end would not work, I guess, since the script would stop before the second item would be deleted...
« Last Edit: November 11, 2010, 07:27:16 AM by Kapryagos »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Problem: DropItem or SceneNode-Saving
« Reply #3 on: November 11, 2010, 07:32:44 AM »

EDIT: Also I have to delete 2 items in one action -- so putting the .DeleteItem cmmandS at the end would not work, I guess, since the script would stop before the second item would be deleted...
The logic is simple, if you are deleting an item, and you are doing it in the script attached to that particular item, the delete command must be the last. So if you combine two items in two different scripts (each attached to one of those items), the two scripts will need to delete the items in different order.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Re: Problem: DropItem or SceneNode-Saving
« Reply #4 on: November 11, 2010, 07:58:11 AM »

Well, concerning that I should note that both item-scripts have a third script included which contains the combining function -- this seems to be the easiest way to make the combination work both ways. (like "1+2=3" equals "2+1=3")

But honestly, my actual problem is that the item disconnection is no more as soon as I re-enter the scene. I checked it (by checking the "this.Item" value of the reappeared scene entity: It is connecte again, but that happens not until I enter the scene. So entering the scene resets the value. What can I do against that?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Problem: DropItem or SceneNode-Saving
« Reply #5 on: November 11, 2010, 08:14:51 AM »

That's expected behavior, this property is not saved by the engine. You'd have to do it the hard way, i.e. remembering that the item is gone in some global variable, and in scene_init.script do some actions if the variable is set.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Re: Problem: DropItem or SceneNode-Saving
« Reply #6 on: November 11, 2010, 03:09:34 PM »

Thanks, Mnemonic -- although my first thought was quite like "omg that sounds annoying like an orange!" it is a quite simple workaround in the end, actually!
I just have to put two lines at the beginning of the scene entity's script and changing the global var within the leftclick event. It works fine! :)

Code: [Select]
global taken_aromata;
if(taken_aromata==1){this.SetSprite(null);}
//... setting "SetSprite" to null may not be the most elegant way to solve it, but it works more flawless than trying it with "Active".
Logged
 

Page created in 0.044 seconds with 20 queries.