Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Can an item delete itself?  (Read 3602 times)

0 Members and 1 Guest are viewing this topic.

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Can an item delete itself?
« on: June 01, 2004, 08:52:47 PM »

When the player combines item X with Y to form item Z, I want item X and Y to be deleted. But when it gets at Game.DeleteItem("X"); it just stops there. Is it because Game.DeleteItem("X"); will not work inside x.script ?
Logged

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Can an item delete itself?
« Reply #1 on: June 01, 2004, 09:03:28 PM »

(deleted)
« Last Edit: June 01, 2004, 09:32:22 PM by Marek »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Can an item delete itself?
« Reply #2 on: June 02, 2004, 08:27:04 AM »

When the player combines item X with Y to form item Z, I want item X and Y to be deleted. But when it gets at Game.DeleteItem("X"); it just stops there. Is it because Game.DeleteItem("X"); will not work inside x.script ?

That's because when the item is deleted, it takes the script with it, so the script is terminated immediately. Frankly, I didn't think of this situation when adding the DeleteItem method and I'll probably look into it, so that at least the script runs to the end before the item is removed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Can an item delete itself?
« Reply #3 on: June 02, 2004, 10:56:53 AM »

OK, cool :)
Both X and Y are objects taken from the scene. If I use DropItem (instead of DeleteItem) they become visible again. Any workarounds?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Can an item delete itself?
« Reply #4 on: June 02, 2004, 11:08:09 AM »

1) Make the DeleteItem last command in the script (it does remove the item eventually, doesn't it? I can't test it right now..)

or

2) Remove the connection between the scene entity and the item so that is stays hidden even after you call DropItem:

Code: [Select]
var SomeEntity = Scene.GetNode("some_entity_representing_the_item");
SomeEntity.Item = ""; // it's no longer affected by taking/dropping the associated item
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Can an item delete itself?
« Reply #5 on: June 02, 2004, 01:01:22 PM »

Muchas gracias.

I used workaround 1) and it worked... around.
Logged
 

Page created in 0.024 seconds with 19 queries.