Page 1 of 1

Add item to alcove

Posted: Wed Aug 19, 2015 8:22 pm
by Kuro01
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.

Code: Select all

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

Re: Add item to alcove

Posted: Wed Aug 19, 2015 8:40 pm
by minmay
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.

This is what you wanted:

Code: Select all

function gearkey()
  ledgerack_3.surface:addItem(spawn("gear_key",nil,nil,nil,nil,nil,"test").item)
end

Re: Add item to alcove

Posted: Wed Aug 19, 2015 8:41 pm
by Kuro01
Thanks

Re: Add item to alcove

Posted: Wed Aug 19, 2015 8:56 pm
by Azel
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.

Code: Select all

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:

function ShowGearKey()

gear_key_1.item:enable()
gear_key_1.model:enable()

end

I did this with a secret note; I assume it would work for a key :?

Re: Add item to alcove

Posted: Wed Aug 19, 2015 9:10 pm
by minmay
don't do that, it will mess up anything that checks the alcove's contents

Re: Add item to alcove

Posted: Wed Aug 19, 2015 9:37 pm
by Azel
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."

Re: Add item to alcove

Posted: Wed Aug 19, 2015 10:03 pm
by Kuro01
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?

Code: Select all

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
another

Code: Select all

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

Re: Add item to alcove

Posted: Sat Aug 22, 2015 9:24 am
by Azel
Hi Kuro,

I made you a dungeon that lets you put items in any 3 Alcoves, and the 4th Alcove will spawn the Gear Key if it is empty.

I put the entire dungeon file on my Mod Website: http://mystrock.com/files/Alcoves.zip

It is a perfectly safe download; I have a few other dungeon files that I share from that location :D

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.

Re: Add item to alcove

Posted: Sun Aug 23, 2015 2:54 pm
by Kuro01
Thanks, Can I get the adress to your mod page, curiouse

Re: Add item to alcove

Posted: Sun Aug 23, 2015 9:41 pm
by Azel
Mod info is on the main site: http://www.mystrock.com

Currently only a Demo is available. The full version will be released in about 5 weeks (at the end of September).

Steam download: http://steamcommunity.com/sharedfiles/f ... =369773173
Nexus Download: http://www.nexusmods.com/legendofgrimrock2/mods/31/?
Direct Download: http://www.mystrock.com/files/pathdemo/ ... elease.zip

This is my first Mod, but the feedback has been quite good so far :mrgreen: