Script options to check if party has various items or not
Script options to check if party has various items or not
I can't write a working script even if my life depend on it and I have to read through the forum looking for the bits I need. However, I can't find this.
I need to check the party for specific items, golden_crown, golden_dragon and golden_orb and open door1 if the party has all of them and door2 if they don't.
Can anyone help with this script?
Does it help if I tell you that I think you all are fantastic and you make amazing stuff? I've been lurking around here for months and I still find things that make me go "wow!" every day.
I need to check the party for specific items, golden_crown, golden_dragon and golden_orb and open door1 if the party has all of them and door2 if they don't.
Can anyone help with this script?
Does it help if I tell you that I think you all are fantastic and you make amazing stuff? I've been lurking around here for months and I still find things that make me go "wow!" every day.
Last edited by Conchron on Sat Feb 09, 2013 12:33 pm, edited 1 time in total.
My Log1 Mod: Master Arrak's Treasure
Re: Can anyone help me with a scrip?
Hi thereConchron wrote:
I need to check the party for specific items, golden_crown, golden_dragon and golden_orb and open door1 if the party has all of them and door2 if they don't.
Can anyone help with this script?
Try this:
viewtopic.php?f=14&t=4903&p=52094&hilit ... eck#p52094
or maybe
viewtopic.php?f=14&t=3099&p=31872&hilit ... eck#p31872
Re: Can anyone help me with a scrip?
Thank you Filipsan, but, I've seen those and I can't put them together so that they do what I need them to do.
My Log1 Mod: Master Arrak's Treasure
Re: Can anyone help me with a scrip?
You can try this, but I warn you, this kind of scripts needs grimq
viewtopic.php?f=14&t=4256&hilit=grimq
because the script I'm going to write will not work if the items are inside sacks, boxes, mortars, ecc...
A script with grimq will provide that kind of stuff, but unfortunately I'm not good using it
Anyway, here's the script, I've tested it and it's working
EDIT:
Okay, I've managed to create a code that seek for items even inside sacks, boxes, etc... and seems working good.
Here's the new code.
Let me know if you have problems
viewtopic.php?f=14&t=4256&hilit=grimq
because the script I'm going to write will not work if the items are inside sacks, boxes, mortars, ecc...
A script with grimq will provide that kind of stuff, but unfortunately I'm not good using it
Anyway, here's the script, I've tested it and it's working
Code: Select all
function checkItems()
local treasure1 = false
local treasure2 = false
local treasure3 = false
local treasures = {
"golden_crown", "golden_dragon", "golden_orb"}
local checks = {
treasure1, treasure2, treasure3}
for i = 1, 4 do
for j = 1, 31 do
local item = party:getChampion(i):getItem(j)
for k, v in ipairs(treasures) do
if item then
if item.name == v then
checks[k] = true
end
end
end
end
end
for i, v in ipairs(checks) do
if not v then
door2:open()
return
end
end
door1:open()
end
Okay, I've managed to create a code that seek for items even inside sacks, boxes, etc... and seems working good.
Here's the new code.
SpoilerShow
Code: Select all
function checkItems()
local treasure1 = false
local treasure2 = false
local treasure3 = false
local treasures = {
"golden_crown", "golden_dragon", "golden_orb"}
local checks = {
treasure1, treasure2, treasure3}
for i = 1, 4 do
for j = 1, 31 do
local item = party:getChampion(i):getItem(j)
for k, v in ipairs(treasures) do
if item then
if item.name == "sack" or item.name == "mortar" or item.name == "wooden_box" then
for x in item:containedItems() do
if x then
if x.name == "mortar" then
for y in x:containedItems() do
if y then
if y.name == v then
checks[k] = true
end
end
end
end
end
if x.name == v then
checks[k] = true
end
end
end
if item.name == v then
checks[k] = true
end
end
end
end
end
for i, v in ipairs(checks) do
if not v then
door2:open()
return
end
end
door1:open()
end
Re: Can anyone help me with a scrip?
my head just pirouetted across the office!
Finished Dungeons - complete mods to play
Re: Can anyone help me with a scrip?
Thank you crisman! That works perfectly.
My Log1 Mod: Master Arrak's Treasure
Re: Can anyone help me with a scrip? (Solved)
minor correction to crisman's very good code:
I just moved an "end" from right before the "if x.name" section to right after it (and adjusted the spacing accordingly), so the "if x" (existence) check above that is still in place for the x.name check
Code: Select all
function checkItems()
local treasure1 = false
local treasure2 = false
local treasure3 = false
local treasures = {
"golden_crown", "golden_dragon", "golden_orb"}
local checks = {
treasure1, treasure2, treasure3}
for i = 1, 4 do
for j = 1, 31 do
local item = party:getChampion(i):getItem(j)
for k, v in ipairs(treasures) do
if item then
if item.name == "sack" or item.name == "mortar" or item.name == "wooden_box" then
for x in item:containedItems() do
if x then
if x.name == "mortar" then
for y in x:containedItems() do
if y then
if y.name == v then
checks[k] = true
end
end
end
end
if x.name == v then
checks[k] = true
end
end
end
end
if item.name == v then
checks[k] = true
end
end
end
end
end
for i, v in ipairs(checks) do
if not v then
door2:open()
return
end
end
door1:open()
end
Finished Dungeons - complete mods to play
Re: Can anyone help me with a scrip? (Solved)
And here's my (squished!) version for a single item:
Code: Select all
function checkGoldOrb()
local goldOrb = false
local n = "golden_orb"
for i = 1, 4 do
for j = 1, 31 do
local item = party:getChampion(i):getItem(j)
if item then
if item.name == "sack" or
item.name == "mortar" or
item.name == "wooden_box" then
for x in item:containedItems() do
if x then
if x.name == "mortar" then
for y in x:containedItems() do
if y then if y.name == n then goldOrb = true end end
end end
if x.name == n then goldOrb = true end
end end end
if item.name == n then goldOrb = true end
end end end
if goldOrb then door1:open() else door2:open() end
end
Finished Dungeons - complete mods to play
Re: Script options to check if party has various items or no
Thanks Komag, didn't notice that
Its' funny that 5 minutes before writing the code I didn't remember that item:contaniedItems() was added to the editor
Surely for an item is way much more simple, like you did!
Its' funny that 5 minutes before writing the code I didn't remember that item:contaniedItems() was added to the editor
Surely for an item is way much more simple, like you did!
Re: Script options to check if party has various items or no
Hi everyone,
Just an additional question - is it possible to check for the 'hand' i.e. if you take something from a champs inventory or equipped hands, the cursor (in game) changes to that object. This script does not detect / check that 'hand' - which is scuppering my plans....
Great forum btw - excellent resource, thanks to all for contributing.
Just an additional question - is it possible to check for the 'hand' i.e. if you take something from a champs inventory or equipped hands, the cursor (in game) changes to that object. This script does not detect / check that 'hand' - which is scuppering my plans....
Great forum btw - excellent resource, thanks to all for contributing.