scripting help
Re: scripting help
I also tried in a new project and same warning
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
Re: scripting help
That's very peculiar that I don't get an error with mine, but yours does.
Okay, try this variation on the script:
This one gives me no errors, but handles things slightly different than before; based on a hunch. The original script did have a bug—though it didn't crash for me. This version fixes that bug.
Okay, try this variation on the script:
Code: Select all
altar_1.surface:addConnector('onAcceptItem', self.go.id, "itemSwap")
function itemSwap(surface, item)
local checkItem = "rock"
local itemReplacement = "figure_skeleton"
if item.go.item:getStackSize() == 1 and
item.go.name == checkItem then
item.go:destroyDelayed()
surface:addItem(spawn(itemReplacement).item)
--optional effect
surface.go:createComponent('Particle'):setParticleSystem('beacon_crystal')
surface.go.particle:setDestroySelf(true)
surface.go.particle:fadeOut(1)
surface.go:playSound('teleport')
return false
end
end
Re: scripting help
that works thank you. 

Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
Re: scripting help
Hi Issac
Tried using your variation of the script but when you place the rock on the altar I end up with 2 'skeleton figurines' every time
and the particle system does not fade out, any ideas?
Tried using your variation of the script but when you place the rock on the altar I end up with 2 'skeleton figurines' every time
and the particle system does not fade out, any ideas?
Re: scripting help
I am trying to use this but instead the player puts some items on a pedestal then hits a button which checks for items and spawns them on the pedastel
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
- Zo Kath Ra
- Posts: 940
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: scripting help
IIRC you wanted a script that turns multiple items into a single new item, like crafting potions.
Code: Select all
function transformItems(button)
local input_item_names = { rock = false, branch = false }
local output_item_name = "cudgel"
local surface
local alcove = findEntity("dungeon_alcove_1")
if alcove and alcove.surface then
surface = alcove.surface
else
print("Entity doesn't exist or has no surface component: dungeon_alcove_1")
return
end
-- If any of the input items is on the surface, mark it as present in input_item_names
for _, item in surface:contents() do
if input_item_names[item.go.name] ~= nil then
input_item_names[item.go.name] = true
end
end
-- If at least one input item is missing from the surface, exit the function
for _, present in pairs(input_item_names) do
if present == false then
return
end
end
-- Destroy the input items
for _, item in surface:contents() do
if input_item_names[item.go.name] == true then
-- Mark the item as destroyed in input_item_names
-- So only one instance of the input item gets destroyed
input_item_names[item.go.name] = false
item.go:destroyDelayed()
end
end
-- Add the output item to the surface
surface:addItem(spawn(output_item_name).item)
playSound("secret")
hudPrint("The alcove has created a new " .. output_item_name .. ".")
end
Re: scripting help
Thanks. How would I make it so it destroys the items even if they are not the right ones?
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699