How to check which item is in alcove?
Re: How to check which item is in alcove?
How do i make this work with 4 specific types of items in a altar? (for example: scroll_fireball, scroll_ice_shards, scroll_poison_bolt, scroll_invisibility)
This code does nothing with all the items on the altar (called elementalAltar). the altar is connected to the script with the any option, and has activate always on.
This code does nothing with all the items on the altar (called elementalAltar). the altar is connected to the script with the any option, and has activate always on.
Code: Select all
function aretheitemsthere()
if containsItem(elementalAltar, "scroll_poison_cloud") and containsItem(elementalAltar, "scroll_ice_shards") and containsItem(elementalAltar, "scroll_fireball") and containsItem(elementalAltar, "scroll_invisibility")
then
ironDoor2:open()
else
ironDoor2:close()
end
end
function containsItem(entity, item)
-- This function returns true if the entity contains a given item.
-- It works for any entity that implements the containedItems() method.
for i in entity:containedItems() do
if i.name == item then
return true
end
end
-- if we get here the item was not found
return false
end
Re: How to check which item is in alcove?
looks like you just need "" around "elementalAltar"
Finished Dungeons - complete mods to play
Re: How to check which item is in alcove?
Hi. first I would like to say that I'm not very good at scripting.
That said I'm also trying to open a door using multiple alcoves. The thing is I want the door to open when the player inserts 1 treasure on each of the 4 alcoves. ANY treasures, not specific ones.
How can I do this? Is there a way I can make the script check for the "Treasure" flag instead of using names?
That said I'm also trying to open a door using multiple alcoves. The thing is I want the door to open when the player inserts 1 treasure on each of the 4 alcoves. ANY treasures, not specific ones.
How can I do this? Is there a way I can make the script check for the "Treasure" flag instead of using names?
Re: How to check which item is in alcove?
Start with this if you have not (I presume you have)
http://www.grimrock.net/modding/how-to- ... ve-puzzle/
Make a list of your treasures (or a table, is it called that in here?), and check for that every time the alcove is accessed. (I'm sure someone can give you a more technical explanation of that part, tables are not something I am really familiar with), then make a counter that decrements each time a treasure is entered into an alcove and incremented when one is taken away.
Connect that counter to the door, so it opens when the counter hits zero. (a counter automatically fires when it hits zero, you only need to connect it, I believe)
You still need to make sure the alcove only counts one treasure per alcove. This can be done simply by checking it in the code before decrementing the counter.
This is a very verbal and even vague explanation -- I didn't have time to test it in the editor. I hope this is of help or that someone can give a more technical explanation. If not, I hope I can make a better attempt at this at a later time.
http://www.grimrock.net/modding/how-to- ... ve-puzzle/
Make a list of your treasures (or a table, is it called that in here?), and check for that every time the alcove is accessed. (I'm sure someone can give you a more technical explanation of that part, tables are not something I am really familiar with), then make a counter that decrements each time a treasure is entered into an alcove and incremented when one is taken away.
Connect that counter to the door, so it opens when the counter hits zero. (a counter automatically fires when it hits zero, you only need to connect it, I believe)
You still need to make sure the alcove only counts one treasure per alcove. This can be done simply by checking it in the code before decrementing the counter.
This is a very verbal and even vague explanation -- I didn't have time to test it in the editor. I hope this is of help or that someone can give a more technical explanation. If not, I hope I can make a better attempt at this at a later time.
BASILEUS
Re: How to check which item is in alcove?
What about check set of items in alcove?
There script may compare any defined items in list with items in alcove.
This way is useful for testing more items of one type.
Code: Select all
function checkItems(alcove)
local ent
local list = {"scroll","arrow","scroll","scroll"} -- set of checked items
table.sort(list) -- short list for correct compare
local inv = table.concat(list,",") -- make string from list for easy compare
local alcoved = {}
for ent in alcove:containedItems() do -- make table of items in alcove
table.insert(alcoved,ent.name)
end
table.sort(alcoved) -- short items
local alc = table.concat(alcoved,",") -- make string
if inv == alc then -- compare two strings - alcoved items / checked items
-- print("good")
return true
end
-- print("bad")
return false
end
This way is useful for testing more items of one type.
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
MultiAlcoveManager, Toolbox, Graphic text,
-
- Posts: 27
- Joined: Mon Feb 10, 2014 5:56 pm
Re: How to check which item is in a CELL
Hey Guys,
i´ve benn trying alot ,
but i cannot find a script that triggers when a specific item is in a cell.
Has anyone an idea? I´ve tried pressure_plates and stuff, but it doesn´t work /:
My Idea was to make an dungeon where you have to grow up your enemys...first button enables a lightsource,
and when a item called "Seed" is placed in a lighted area, an enemy "grows" (mbe after 3 seconds or so):..
i´ve benn trying alot ,
but i cannot find a script that triggers when a specific item is in a cell.
Has anyone an idea? I´ve tried pressure_plates and stuff, but it doesn´t work /:
My Idea was to make an dungeon where you have to grow up your enemys...first button enables a lightsource,
and when a item called "Seed" is placed in a lighted area, an enemy "grows" (mbe after 3 seconds or so):..
Re: How to check which item is in alcove?
Try this:
Script returns the i.name (item name) if found.
If your item has a specific Id, better ask with i.id
Code: Select all
for i in entitiesAt(place.level,place.x,place.y) do
if i.name == "that_item" then
hudPrint("Your item is found: "..i.name)
else return false
If your item has a specific Id, better ask with i.id
Dungeon Master Resource Pack worker and passionated Beer drinker
-
- Posts: 27
- Joined: Mon Feb 10, 2014 5:56 pm
Re: How to check which item is in alcove?
I think thath this could work well, but i guess i have to stop the for loop,
like with a break script.
and i have another Question:
How can i make my own"Seeds" (imported the model of green gems and renamed it) open the Demons maze?
like with a break script.
and i have another Question:
How can i make my own"Seeds" (imported the model of green gems and renamed it) open the Demons maze?
Re: How to check which item is in alcove?
Code: Select all
for i in entitiesAt(place.level,place.x,place.y) do
if i.name == "that_item" then
hudPrint("Your item is found: "..i.name)
else return false
end
end
Dungeon Master Resource Pack worker and passionated Beer drinker