function opendoor()
if ht1:hasgolden_chalice() and
ht2:hasgolden_crown() and
ht3:hasgolden_dragon() and
ht4:hasgolden_figure() and
ht5:hasgolden_goromorg() and
ht6:hasgolden_orb() then
td:open()
else
td:close()
end
end
i am trying to have a door open when all those items are placed on alcoves, why doesn't it work?
have also tried a differnt setting:
function itemPuzzle()
if itemPuzzleAlcove1 == "golden_chalice" and
itemPuzzleAlcove2 == "golden_crown" and
itemPuzzleAlcove3 == "golden_dragon" and
itemPuzzleAlcove4 == "golden_figure" and
itemPuzzleAlcove5 == "golden_goromorg" and
itemPuzzleAlcove6 == "golden_orb" then
tdoor:open()
else
tdoor:close()
end
end
still without success
Scrip Help plz
-
- Posts: 52
- Joined: Sun Feb 10, 2013 12:46 am
- Location: Dorchester, MA, USA
Re: Scrip Help plz
Hi Meraz.
implies that ht1 is a lua table of some sort, and "hasgolden_chain" is a key which indexes some function within that table. What exactly happens when you run the function opendoor ? Also, what calls opendoor (e.g. a connector or another script)?
In your other script example:
I suspect that what you want is more like this:
Each alcove should have a connector that targets your script_entity , Action = itemPuzzle . Note that this will only check for the presence of the desired items, it ignores any extraneous items. Hope this helps 
Without seeing your mod in the editor, a lot of those identifiers are out-of-context. You have several identifiers following the pattern "ht#" - what are these? The syntax:Meraz wrote:Code: Select all
function opendoor() if ht1:hasgolden_chalice() and ht2:hasgolden_crown() and ht3:hasgolden_dragon() and ht4:hasgolden_figure() and ht5:hasgolden_goromorg() and ht6:hasgolden_orb() then td:open() else td:close() end end
Code: Select all
ht1:hasgolden_chalice()
In your other script example:
I think that "itemPuzzleAlcove#" is the identifier for one of the alcoves in your puzzle. As a dungeon object, this will always be a table. In this code, you are comparing tables to strings (e.g. "golden_chalice"), but tables are never equal to strings, so the lua interpreter will always reach the line tdoor:close() , never tdoor:open() . Again, what calls itemPuzzle ?Meraz wrote:Code: Select all
function itemPuzzle() if itemPuzzleAlcove1 == "golden_chalice" and itemPuzzleAlcove2 == "golden_crown" and itemPuzzleAlcove3 == "golden_dragon" and itemPuzzleAlcove4 == "golden_figure" and itemPuzzleAlcove5 == "golden_goromorg" and itemPuzzleAlcove6 == "golden_orb" then tdoor:open() else tdoor:close() end end
I suspect that what you want is more like this:
Code: Select all
function itemPuzzle()
if alcoveContainsItem( "itemPuzzleAlcove1" , "golden_chalice" ) and
alcoveContainsItem( "itemPuzzleAlcove2" , "golden_crown" ) and
alcoveContainsItem( "itemPuzzleAlcove3" , "golden_dragon" ) and
alcoveContainsItem( "itemPuzzleAlcove4" , "golden_figure" ) and
alcoveContainsItem( "itemPuzzleAlcove5" , "golden_goromorg" ) and
alcoveContainsItem( "itemPuzzleAlcove6" , "golden_orb" ) then
tdoor:open()
else
tdoor:close()
end
end
alcoveContainsItem = function( alcoveName , itemName )
local alcove = findEntity( alcoveName )
if not alcove then
return false
end
for item in alcove:containedItems() do
if item.name == itemName then
return true
end
end
return false
end

Re: Scrip Help plz
I will give it a try, thanks =) ..Never tried scripting anything before this game so I am still learning the do's and don'ts..
Last edited by Meraz on Thu Mar 14, 2013 10:48 am, edited 1 time in total.
Re: Scrip Help plz
Woot it worked like a charm, your awsome dude thanks alot !
Re: Scrip Help plz
Hi Fellas!
Marble Mouth, you have helped me out yet again with what I was I stumped on (doing complicated things with tables!!)
So I thought I would drop you a line and say thanks ... also share what I have done with it...
I have expanded on the head hunter trait - basically 'normal skull' bonuses to attack power dont work anymore... there are pieces of armour (which are actually 'sack' containers) that you must adorn with different kinds of skulls, bones, horns, teeth etc. Then you have a grimoire for each piece of armour which you can right click on check on the combinations of skulls etc you have on/inside your armour.
From there, the party finds clues and recipes for combinations of bones and skulls which they can collect and add together >>> which will give the champion good (and different) bonuses.
I was really struggling with how to table this all up but thanks to your example, all sorted now
These are the items involved currently (but Im going to cut it down a bit)
So you right click use the grimoire to check the contents of your bonecraft armour... which calls this script in dungeon:
Currently I still have to position the bones and skulls into the armour containers according to exact slots, but still!!! Thank you for helping me out on this one

Marble Mouth, you have helped me out yet again with what I was I stumped on (doing complicated things with tables!!)
So I thought I would drop you a line and say thanks ... also share what I have done with it...
I have expanded on the head hunter trait - basically 'normal skull' bonuses to attack power dont work anymore... there are pieces of armour (which are actually 'sack' containers) that you must adorn with different kinds of skulls, bones, horns, teeth etc. Then you have a grimoire for each piece of armour which you can right click on check on the combinations of skulls etc you have on/inside your armour.
From there, the party finds clues and recipes for combinations of bones and skulls which they can collect and add together >>> which will give the champion good (and different) bonuses.
I was really struggling with how to table this all up but thanks to your example, all sorted now

These are the items involved currently (but Im going to cut it down a bit)
SpoilerShow
Code: Select all
cloneObject{
name = "skull_plain",
baseObject = "skull",
uiName = "Skull",
model = "assets/models/items/skull.fbx",
gfxIndex = 31,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A plain humanoid skull... picked cleaned and well dried.",
}
defineObject{
name = "skull_blood_soaked",
class = "Item",
gfxAtlas = "mod_assets/textures/icons/items_s.tga",
uiName = "Blood Soaked Skull",
model = "mod_assets/models/blood_soaked_skull.fbx",
gfxIndex = 30,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A humanoid skull... saturated and set in blood. This indicates a time of war between races...",
}
defineObject{
name = "skull_stone",
class = "Item",
gfxAtlas = "mod_assets/textures/icons/items_s.tga",
uiName = "Cursebone Skull",
model = "mod_assets/models/stone_skull.fbx",
gfxIndex = 29,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A dark humanoid skull... the dark bone colour indicates it has coloured due to age or magic...or a curse!",
}
defineObject{
name = "skull_crystal",
class = "Item",
uiName = "Crystal Skull",
model = "mod_assets/models/crystal_skull.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons3.tga",
gfxIndex = 31,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A crystal skull... picked cleaned and well dried.",
}
defineObject{
name = "skull_horned",
class = "Item",
gfxAtlas = "mod_assets/textures/icons/items_s.tga",
uiName = "Horned Skull",
model = "mod_assets/models/horned_skull.fbx",
gfxIndex = 32,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A bovine skull... most of the horns are removed. This usually indicates betrayal or tradgedy within a Tribe or Clan...",
}
defineObject{
name = "skull_bloody",
class = "Item",
gfxAtlas = "mod_assets/textures/icons/items_s.tga",
uiName = "Bloody Skull",
model = "mod_assets/models/bloody_skull.fbx",
gfxIndex = 31,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A humanoid skull... splattered with blood on the crown. This indicates the skull belonged to someone high born or important...",
}
defineObject{
name = "skull_reptilian",
class = "Item",
uiName = "Reptilian Skull",
model = "mod_assets/models/reptilian_skull.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 16,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A reptilian skull... cracked and cleaned. This means the wearer is very agile and has quick reflexes...",
}
defineObject{
name = "horn_beast",
class = "Item",
uiName = "Beast Horn",
model = "mod_assets/models/beast_horn.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 45,
weight = 1.0,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A beast horn... cleaned and polished. This means the wearer hunts beasts bigger than they are...",
}
defineObject{
name = "bone_amulet",
class = "Item",
uiName = "Bone Amulet",
model = "assets/models/items/bone_amulet.fbx",
gfxIndex = 65,
weight = 0.2,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A primitive amulet made out of small bones... females often wear necklace type ornaments to impress and seduce males",
}
defineObject{
name = "bone_dagger",
class = "Item",
uiName = "Bone Dagger",
model = "mod_assets/models/bone_dagger.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 47,
weight = 0.2,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A dagger meant for ornamental or ritual purposes...",
}
defineObject{
name = "bone_beast",
class = "Item",
uiName = "Beast Bone",
model = "mod_assets/models/beast_bone.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 44,
weight = 0.2,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A large bone from a beasts arm or leg... such a large bone portents a raise in status or advancement.",
}
defineObject{
name = "tooth_lizard",
class = "Item",
uiName = "Lizard Fang",
model = "mod_assets/models/lizard_tooth.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 48,
weight = 0.2,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A toothknocked free from a giant lizard... this indicates a great feast is bound to happen soon...",
}
defineObject{
name = "tooth_scavenger",
class = "Item",
uiName = "Scavenger Teeth",
model = "mod_assets/models/lizard_tooth.fbx",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
gfxIndex = 46,
weight = 0.2,
gameEffect = "Bonecraft: attach combinations of various bones/skulls to a bonecraft belt/armour/mask for bonuses.",
description = "A small collection of teeth taken from scavengers... depending on breed of scavenger, this can indicate great wealth.",
}
cloneObject{
name = "trophy_belt",
baseObject = "sack",
uiName = "Tribal Bonecraft Belt",
gfxAtlas = "mod_assets/textures/akroma_icons.tga",
model = "assets/models/items/ring_greaves.fbx",
gfxIndex = 25,
slot = "Legs",
container = true,
containerType = "sack",
capacity = 6,
protection = 3,
weight = 0.5,
gameEffect = "Bonecraft: champions with the 'Head-hunter' trait only.",
description = "A Minotaur tribal belt for hanging battle momentos and souvenirs. Minotaurs from all professions make good use of their bonecraft belts.",
}
cloneObject{
name = "shaman_crown",
baseObject = "sack",
uiName = "Shaman Bonecraft Mask",
gfxAtlas = "mod_assets/textures/akroma_icons4.tga",
model = "mod_assets/models/shaman_crown.fbx",
gfxIndex = 66,
slot = "Head",
container = true,
containerType = "sack",
capacity = 6,
protection = 4,
willpower = 2,
energhy = 20,
weight = 0.5,
gameEffect = "Bonecraft: champions with the 'Head-hunter' trait only.",
description = "A ritualistic head piece for attaching small bones and other beastly remains. This kind of mask represents Bonrcraft Shamans across the Northern Realms.",
}
cloneObject{
name = "warchief_vest",
baseObject = "sack",
uiName = "Warchief Bonecraft Armour",
gfxAtlas = "mod_assets/textures/akroma_icons4.tga",
model = "assets/models/items/leather_clothes.fbx",
gfxIndex = 65,
slot = "Torso",
container = true,
containerType = "sack",
capacity = 6,
health = 20,
protection = 8,
strength = 2,
weight = 0.5,
gameEffect = "Bonecraft: champions with the 'Head-hunter' trait only.",
description = "Decorated armour worn by Clan Chieftans Warlords. Minotuars still attach skulls and other bones to their armour as a sign of superiority within their tribe and a bizarre form of respect to those who have fallen in battle bravely.",
}
cloneObject{
name = "grimoire_bone_crafting_1",
baseObject = "tome_health",
uiName = "Grimoire of Belt Bonecraft",
gfxAtlas = "mod_assets/textures/akroma_icons2.tga",
model = "mod_assets/models/grimoire_bonecraft.fbx",
gfxIndex = 9,
gameEffect = "Bonecraft Belt: You can hang skulls and bones from this belt to discover Bonecraft Enchantments.",
description = "An essential Grimoire that - upon use - will detect any significant Shamanistic combinations of skulls/bones worn by the user (items must be held within an equiped bonecraft belt).",
weight = 2.5,
onUseItem = function(item,champion)
hudPrint("The Grimoire glows and cycles through the components held by the equipped bonecraft belt...")
return headhunterScript.beltCombinationsEquip(item, champion)
end
}
cloneObject{
name = "grimoire_bone_crafting_2",
baseObject = "tome_health",
uiName = "Grimoire of Armour Bonecraft",
gfxAtlas = "mod_assets/textures/akroma_icons2.tga",
model = "mod_assets/models/grimoire_bonecraft.fbx",
gfxIndex = 9,
gameEffect = "Bonecraft Armour: You can attach skulls and bones on this armour to discover Bonecraft Enchantments.",
description = "An essential Grimoire that - upon use - will detect any significant Shamanistic combinations of skulls/bones worn by the user (items must be held within an equiped bonecraft armour).",
weight = 2.5,
onUseItem = function(item,champion)
hudPrint("The Grimoire glows and cycles through the components held by the equipped bonecraft armour...")
return headhunterScript.armourCombinationsEquip(item, champion)
end
}
cloneObject{
name = "grimoire_bone_crafting_3",
baseObject = "tome_health",
uiName = "Grimoire of Ritual Mask Bonecraft",
gfxAtlas = "mod_assets/textures/akroma_icons2.tga",
model = "mod_assets/models/grimoire_bonecraft.fbx",
gfxIndex = 9,
gameEffect = "Bonecraft Mask: You can fit skulls and bones to this mask to discover Bonecraft Enchantments.",
description = "An essential Grimoire that - upon use - will detect any significant Shamanistic combinations of skulls/bones worn by the user (items must be held within an equiped bonecraft mask).",
weight = 2.5,
onUseItem = function(item,champion)
hudPrint("The Grimoire glows and cycles through the components held by the equipped bonecraft mask/s...")
return headhunterScript.maskCombinationsEquip(item, champion)
end
}
So you right click use the grimoire to check the contents of your bonecraft armour... which calls this script in dungeon:
SpoilerShow
Code: Select all
bonecraftContainers = { "trophy_belt", "shaman_crown" , "warchief_vest" }
function isInTable(table, element)
for _,value in pairs(table) do
if value == element then
return true
end
end
return false
end
function beltCombinationsEquip(item, champion)
if containerContainsItem( "trophy_belt" , "skull_plain" , "skull_plain" , "skull_blood_soaked" , "skull_blood_soaked" ,
"tooth_lizard" , "tooth_lizard" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "trophy_belt" , "skull_reptilian" , "horn_beast" , "horn_beast" , "horn_beast" , "bone_dagger" ,
"bone_dagger" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "trophy_belt" , "skull_reptilian" , "horn_beast" , "bone_beast" , "bone_amulet" , "tooth_lizard" ,
"bone_dagger") then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
else
hudPrint("The bonecraft ritual is incomplete, other components are needed")
playSound("spellfizzle1")
return false
end
end
function armourCombinationsEquip(item, champion)
if containerContainsItem( "warchief_vest" , "skull_horned" , "bone_amulet" , "skull_blood_soaked" , "skull_blood_soaked" ,
"tooth_lizard" , "tooth_lizard") then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "warchief_vest" , "skull_horned" , "tooth_lizard" , "tooth_lizard" , "tooth_lizard" , "bone_dagger" ,
"bone_dagger") then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "warchief_vest" , "skull_stone" , "horn_beast" , "horn_beast" , "bone_beast" , "bone_beast" ,
"bone_beast" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
else
hudPrint("The bonecraft ritual is incomplete, other components are needed")
playSound("spellfizzle1")
return false
end
end
function maskCombinationsEquip(item, champion)
if containerContainsItem( "shaman_crown" , "skull_horned" , "horn_beast" , "horn_beast" , "skull_crystal" , "tooth_lizard" ,
"tooth_lizard" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "shaman_crown" , "skull_reptilian" , "skull_stone" , "skull_stone" , "tooth_scavenger" ,
"tooth_lizard" , "tooth_lizard" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
elseif containerContainsItem( "shaman_crown" , "skull_stone" , "horn_beast" , "horn_beast" , "bone_beast" , "bone_beast" ,
"tooth_scavenger" ) then
hudPrint("The bonecraft ritual is complete, YAY!!!")
playSound("level_up")
return false
else
hudPrint("The bonecraft ritual is incomplete, other components are needed")
playSound("spellfizzle1")
return false
end
end
containerContainsItem = function( containerName , boneName1 , boneName2 , boneName3 , boneName4 , boneName5 , boneName6 )
for i = 1 , 4 do
for p = 1 , 11 do
local container = party:getChampion(i):getItem(p)
if container and isInTable(bonecraftContainers, container.name) then
if container.name == "trophy_belt" then
for item in container:containedItems() do
for p = 1 , 6 do
local e = container:getItem(p)
if e == nil then
return false
elseif (container:getItem(1) ~= nil and container:getItem(1).name == boneName1) and
(container:getItem(2) ~= nil and container:getItem(2).name == boneName2) and
(container:getItem(3) ~= nil and container:getItem(3).name == boneName3) and
(container:getItem(4) ~= nil and container:getItem(4).name == boneName4) and
(container:getItem(5) ~= nil and container:getItem(5).name == boneName5) and
(container:getItem(6) ~= nil and container:getItem(6).name == boneName6) then
return true
end
end
end
elseif container.name == "warchief_vest" then
for item in container:containedItems() do
for p = 1 , 6 do
local e = container:getItem(p)
if e == nil then
return false
elseif (container:getItem(1) ~= nil and container:getItem(1).name == boneName1) and
(container:getItem(2) ~= nil and container:getItem(2).name == boneName2) and
(container:getItem(3) ~= nil and container:getItem(3).name == boneName3) and
(container:getItem(4) ~= nil and container:getItem(4).name == boneName4) and
(container:getItem(5) ~= nil and container:getItem(5).name == boneName5) and
(container:getItem(6) ~= nil and container:getItem(6).name == boneName6) then
return true
end
end
end
elseif container.name == "shaman_crown" then
for item in container:containedItems() do
for p = 1 , 6 do
local e = container:getItem(p)
if e == nil then
return false
elseif (container:getItem(1) ~= nil and container:getItem(1).name == boneName1) and
(container:getItem(2) ~= nil and container:getItem(2).name == boneName2) and
(container:getItem(3) ~= nil and container:getItem(3).name == boneName3) and
(container:getItem(4) ~= nil and container:getItem(4).name == boneName4) and
(container:getItem(5) ~= nil and container:getItem(5).name == boneName5) and
(container:getItem(6) ~= nil and container:getItem(6).name == boneName6) then
return true
end
end
end
else
hudPrint("You must be wearing bonecraft armour and have the correct combination of components for the
ritual...")
playSound("spellfizzle1")
return false
end
end
end
end
end


Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)