Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
EDIT: completely non-functional edited version of script removed
(see below)
(see below)
Last edited by akroma222 on Sat Nov 26, 2016 2:27 pm, edited 1 time in total.
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Ask a simple question, get a simple answer
In the user scripting interface, you cannot remove an item from a surface except by destroying the item.
Yes, I have code for adding an item to the map. This is not code for removing an item from a surface. It's code for adding an item to the map. It won't help with your surface problem. Nothing will help with your surface problem.
Here is the original code in context, by the way, instead of a completely non-functional edited version.
Yes, I have code for adding an item to the map. This is not code for removing an item from a surface. It's code for adding an item to the map. It won't help with your surface problem. Nothing will help with your surface problem.
Here is the original code in context, by the way, instead of a completely non-functional edited version.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Oh well. Guess I'll have to stay with removing the surface component.
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
Even destroying the SurfaceComponent won't help. The item will remain tainted and cause a crash upon pickup (if you didn't re-create the SurfaceComponent) or very bad behaviour/possibly another crash upon loading the game (if you did). I repeat: In the user scripting interface, you cannot remove an item from a surface except by destroying the item.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
I am re-creating the component, and the item doesn't seem to cause any issues afterwards.minmay wrote:Even destroying the SurfaceComponent won't help. The item will remain tainted and cause a crash upon pickup (if you didn't re-create the SurfaceComponent) or very bad behaviour/possibly another crash upon loading the game (if you did). I repeat: In the user scripting interface, you cannot remove an item from a surface except by destroying the item.
No crashes after loading and the item functions normally ¯\_(ツ)_/¯
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
It might not seem to cause any issues but the fact is that this leaves the ItemComponent in an incorrect state. The item will still be marked as if it is in the SurfaceComponent, but the SurfaceComponent will not contain the item.
Therefore:
- picking up the item will trigger the onRemoveItem hook of the SurfaceComponent
- the item will not be pushed correctly, pickup location will be restricted, etc.
- ...unless you save and reload the game
I suppose it's possible that adding it to another inventory immediately (surface, container, monster, champion) would clean this up, but I am not at all comfortable saying that, since I do not have the source code.
Therefore:
- picking up the item will trigger the onRemoveItem hook of the SurfaceComponent
- the item will not be pushed correctly, pickup location will be restricted, etc.
- ...unless you save and reload the game
I suppose it's possible that adding it to another inventory immediately (surface, container, monster, champion) would clean this up, but I am not at all comfortable saying that, since I do not have the source code.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
The issue with triggering onRemove is fixed with not giving the component any connectors.
I've faced the pickup issue, and I fixed it by placing it inside the player inventory before it's on the map. Since it'll probably annoy the user, I made it go through a monster before being set the the mouse item. That fixed it.
Only issue I'm having right now is a crash caused by leaving full screen ('F') after the item was in a surface component, added to a monster, the monster killed, the item set as the cursor item, and the surface removed and re-added.
It only happens in the editor though, so it'll just be a pain in the ass to test with.
EDIT: Also there's the part where people will be using that in the editor, so I should do something about it... eeeeeeeeeeeh
I've faced the pickup issue, and I fixed it by placing it inside the player inventory before it's on the map. Since it'll probably annoy the user, I made it go through a monster before being set the the mouse item. That fixed it.
Only issue I'm having right now is a crash caused by leaving full screen ('F') after the item was in a surface component, added to a monster, the monster killed, the item set as the cursor item, and the surface removed and re-added.
It only happens in the editor though, so it'll just be a pain in the ass to test with.
EDIT: Also there's the part where people will be using that in the editor, so I should do something about it... eeeeeeeeeeeh
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
I'm still confused by this dicussion...
So it is not a matter if I destroy an item from a surface by item_01:destroy() Right? (I do this a lot in my mod - all items will never be used in my dungeon anymore)
There is just a problem if I want to do something else with my item?
So it is not a matter if I destroy an item from a surface by item_01:destroy() Right? (I do this a lot in my mod - all items will never be used in my dungeon anymore)
There is just a problem if I want to do something else with my item?
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Thats the problem - I can't destroy the item because I need it.
Guess I could go with destroying the old item and creating a new one then modify it, but I don't know if it'll have any drastic effects on the game because that process will be repeated. A lot.
Minmay, will destroying the old item and creating a new one (the modify it to my desires) will affect the game in a bad way considering this will happen a lot?
Guess I could go with destroying the old item and creating a new one then modify it, but I don't know if it'll have any drastic effects on the game because that process will be repeated. A lot.
Minmay, will destroying the old item and creating a new one (the modify it to my desires) will affect the game in a bad way considering this will happen a lot?
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
Destroying the item is fine. When an ItemComponent is destroyed, if it's inside a SurfaceComponent it will tell that SurfaceComponent that it was removed. On the other hand, if you destroy a SurfaceComponent, and it contains items, it won't tell the items that they aren't in the (now nonexistent) surface anymore, which is why this problem appears.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.