Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Hello, I'm trying to spawn an item(key) on and alcove or an altar after triggered by lever. Can someone help.
What I got so far but not sure what else to add.
1. Your method call syntax is backwards: the function goes on the right side, and the table it belongs to goes on the left side. http://www.lua.org/manual/5.2/manual.html Also, the addItem function belongs to the SurfaceComponent, not the GameObject.
2. You need to actually spawn the gear key, and pass its ItemComponent to SurfaceComponent:addItem().
3. There is no need to add the gear key to the map yourself if you are going to put it on a surface anyway.
Kuro01 wrote:Hello, I'm trying to spawn an item(key) on and alcove or an altar after triggered by lever. Can someone help.
What I got so far but not sure what else to add.
function gearkey()
spawn("gear_key",1,0,0,0,0,"test")
end
or
function gearkey()
addItem:ledgerack_3("gear_key",3,7,1,0,0,"test")
end
I like to cheat with stuff like this. I will use the Editor to place the gear key inside of the Alcove, and simply "hide" it using the regular user interface by "unchecking" the ITEM and MODEL properties. Then, when a lever/button/trigger is activated, I have a Counter that decrements from 0 to 1, and onActivate of the counter, simply call a basic function:
minmay wrote:don't do that, it will mess up anything that checks the alcove's contents
Not true. Just exclude the hidden item during the contents loop check.
I allow a user to enter a gem in to the Alcove, and when a lever is pulled, the gem is removed and a hidden note is revealed. The user can place their entire armor and weapon set in the Alcove if they like, nothing "messes up."
Hey me again, I got the item to spawn the way i want on the ledge but having trouble using a combination alcove thing. I have 4 alcoves, I want 3 of them with items on surface and 1 of them without to spawn the key. I been trying these but I get errors. How would i set the ledge connector if no toggle available.Is it both insert and remove, decrement andincrement?
function checkAlcove()
if hunger_ledge_alcove_1a.surface:isActivated() and
hunger_ledge_alcove_2a.surface:isActivated() and
hunger_ledge_alcove_3a.surface:isActivated() and not
hunger_ledge_alcove_4a.surface:isActivated() then
hunger_ledge_alcove_1a.surface:addItem(spawn("gear_key",3,7,1,0,1,"test").item)
end
end
function checkAlcove()
if hunger_ledge_alcove_1a.surface:getValue() == 1 and
hunger_ledge_alcove_1a.surface:getValue() == 0 and
hunger_ledge_alcove_1a.surface:getValue() == 0 and
hunger_ledge_alcove_1a.surface:getValue() == 0 then
hunger_ledge_alcove_1a.surface:addItem(spawn("gear_key",3,7,1,0,1,"test").item)
end
end
It is a perfectly safe download; I have a few other dungeon files that I share from that location
I'm going to link this Alcoves dungeon file in Eleven Warriors Modding thread as well. If anyone else has any fun Alcove requests then let me know and I can try to add them.