Page 1 of 1
spawning an altar with an item on it. pls help!
Posted: Fri Jul 28, 2017 12:50 am
by Xardas
I have the problem that i don't know how to spawn an altar with an item on it.
I tried it with this script:
function altarspawn()
Spawn (“altar“, level, x, y, facing) :addItem(spawn(“item_name“))
end
It seems that the problem i have is somewhere in the addItem function,
because the script works just fine by just spawning the altar.
Maybe i'm just making a horrible mistake, because scripting is new to me.
Can anyone help me please?
Re: spawning an altar with an item on it. pls help!
Posted: Fri Jul 28, 2017 3:16 am
by Isaac
Welcome to the forum Xardas!
This script looks like it originally comes from LoG1; but this is the LoG2 section of the forum. (Are you working with LoG1 or LoG2?)
*
When posting a script example on the forum, it's best to use the code tags around script, as it prints the text unformatted, and allows easy selection of the text.
Here is a working LoG1 version:
Code: Select all
function altarspawn()
spawn(“altar“, level, x, y, facing):addItem(spawn(“item_name“))
end
If you are working in LoG2, know that the LoG2 addItem function expects an item component, not an object class name; and (for an altar) it is a function of the altar's surface component. Also, the LoG2 spawn function needs the object's elevation.
Here is a working LoG2 version:
Code: Select all
function altarspawn()
spawn(“altar“, level, x, y, facing, elevation).surface:addItem(spawn(“item_name“).item)
end
If you are starting out in LoG2 scripting, there is a more up-to-date version of the scripting reference than the one on this site. It includes the new script features available in the latest LoG2 updates.
https://github.com/JKos/log2doc/wiki
Re: spawning an altar with an item on it. pls help!
Posted: Fri Jul 28, 2017 12:30 pm
by Xardas
Thanks for the quick answer Isaac.
Seems like this list might just be the thing, that i needed.
I didn't find it, so i just used the Grimrock 1 list, thinking it would would also work for Grimrock 2.