If they pick up the item in the surface that it was "moved" to, that's what can cause a crash after save/load.Isaac wrote:Even before, the player was not able to pick up any 'removed' items, so it doesn't seem to matter for limited [special case] use.
[SOLVED] multiple clickable component
Re: [SOLVED] multiple clickable component
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.
Re: [SOLVED] multiple clickable component
Either not having it accessible at all [off map], or not having a clickable component on the object... but it does not seem possible to actually pick up the [invisible] object from the original surface. If the surface is empty, it can be destroyed, (anything with a game object in the surface must be destroyed first, or it gets left behind, and the game halts if they click on the items when it tries to check if it's possible to reach the object.)minmay wrote:If they pick up the item in the surface that it was "moved" to, that's what can cause a crash after save/load.Isaac wrote:Even before, the player was not able to pick up any 'removed' items, so it doesn't seem to matter for limited [special case] use.
I think it would be easy to write a function that tallies the contained items, removes the intended target (being moved) from it's stored table, and destroys the alcove; replacing it with one that has the original contents from the stored table, sans the moved item.
Re: [SOLVED] multiple clickable component
Yes, you can't pick it up from the original surface because the OBJECT is moved to the other surface. The ITEM COMPONENT is still REFERENCED by BOTH. SURFACES. So when you pick up the item from one surface, the object is removed from the map, but the other surface STILL HAS A REFERENCE TO IT.Isaac wrote:Either not having it accessible at all [off map], or not having a clickable component on the object... but it does not seem possible to actually pick up the [invisible] object from the original surface. If the surface is empty, it can be destroyed, (anything with a game object in the surface must be destroyed first, or it gets left behind, and the game halts if they click on the items when it tries to check if it's possible to reach the object.)minmay wrote:If they pick up the item in the surface that it was "moved" to, that's what can cause a crash after save/load.Isaac wrote:Even before, the player was not able to pick up any 'removed' items, so it doesn't seem to matter for limited [special case] use.
Yes, you can do it by destroying SurfaceComponents, this is like the very first thing I mentioned...Isaac wrote:I think it would be easy to write a function that tallies the contained items, removes the intended target (being moved) from it's stored table, and destroys the alcove; replacing it with one that has the original contents from the stored table, sans the moved 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.
Re: [SOLVED] multiple clickable component
Both of these are obvious.minmay wrote:So when you pick up the item from one surface, the object is removed from the map, but the other surface STILL HAS A REFERENCE TO IT.
Yes, you can do it by destroying SurfaceComponents, this is like the very first thing I mentioned...Isaac wrote:I think it would be easy to write a function that tallies the contained items, removes the intended target (being moved) from it's stored table, and destroys the alcove; replacing it with one that has the original contents from the stored table, sans the moved item.
Are you reading my posts as some sort of one-up-manship?
- Zo Kath Ra
- Posts: 944
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: [SOLVED] multiple clickable component
How do you script a dropMouseItem() function?Isaac wrote:*We should request a champion:dropItem() function the next time Petri offers a Glögg session; dropMouseItem() would be useful too.
I need one for a keyring I'm working on.
Re: [SOLVED] multiple clickable component
I would think the way to go about it is t define the key ring as a sack (complete with empty ring and 1,2,3, and 'several' key models and icons); change them out the same way the sack code changes the appearance of the sack.Zo Kath Ra wrote:How do you script a dropMouseItem() function?Isaac wrote:*We should request a champion:dropItem() function the next time Petri offers a Glögg session; dropMouseItem() would be useful too.
I need one for a keyring I'm working on.
If you need to force it to be dropped (via script), spawn a surface at the party's feet (ground level), with a connector from it to a function that counts the contents of the surface, and destroys it when the last item is removed from it.
Then loop through the party's inventory until you find the key ring, and add it to the ground surface, and remove it from the party. This should leave it sitting [seemingly] on the ground, and removes the temporary surface whenever the item is picked up.
- Zo Kath Ra
- Posts: 944
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: [SOLVED] multiple clickable component
Thank you, that worksIsaac wrote:If you need to force it to be dropped (via script), spawn a surface at the party's feet (ground level), with a connector from it to a function that counts the contents of the surface, and destroys it when the last item is removed from it.
Then loop through the party's inventory until you find the key ring, and add it to the ground surface, and remove it from the party. This should leave it sitting [seemingly] on the ground, and removes the temporary surface whenever the item is picked up.
But why doesn't this work?
Code: Select all
function dropMouseItem()
local mouse_item = getMouseItem()
if (mouse_item ~= nil) then
local altar = spawn("altar", party.level, party.x, party.y, party.facing, party.elevation)
altar.surface:addItem(mouse_item)
setMouseItem(nil)
mouse_item.go:setPosition(party.x, party.y, party.facing, party.elevation, party.level)
altar:destroy()
end
endCode: Select all
[string "Party.lua"]:0: attempt to perform arithmetic on field 'x' (a nil value)
stack traceback:
[string "Party.lua"]: in function 'canReach2'
[string "Item.lua"]: in function 'onClickComponent'
[string "GameMode.lua"]: in function 'mousePressed'
[string "GameMode.lua"]: in function 'update'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk