Thanks for taking the time to do that crisman.
I'm using assett rocks. I made 12 of them each one with a different weight so the puzle is to find the magic weight that they all equal out too.
And all the weights are coming out right. Not sure why they are not showing equal when the hudPrint cleary shows both variables are the same. Or why it worked once.
Now that I know it is working on your system I will keep plugging away at it.
And thanks for the heads up about not needing all the checks. I did it similiar to your suggestion first but when it didn't work I added the other stuff to try and troubleshoot it.
If you are interested the whole code is
Code: Select all
--Must have three weightstones in each of 4 alcoves and combined
--weights must match.
function allThingsEqual()
local isPunished = false
-- check for three items
if ScaleAlcove1:getItemCount() ~= 3 then
hudPrint("There are an incorrect number of items in Alcove 1")
hudPrint("You have been punished!")
isPunished = true
end
if isPunished == false then
if ScaleAlcove2:getItemCount() ~= 3 then
hudPrint("There are and incorrect number of items in Alcove 2")
hudPrint("You have been punished!")
isPunished = true
end
end
if isPunished == false then
if ScaleAlcove3:getItemCount() ~= 3 then
hudPrint("There are and incorrect number of items in Alcove 3")
hudPrint("You have been punished!")
isPunished = true
end
end
if isPunished == false then
if ScaleAlcove4:getItemCount() ~= 3 then
hudPrint("There are and incorrect number of items in Alcove 4")
hudPrint("You have been punished!")
isPunished = true
end
end
--Check that all items are weightstones
if isPunished == false then
for i in ScaleAlcove1:containedItems() do
if i.name:sub(1,11) ~= "weightstone" then
hudPrint("There is an incorrect item in Alcove 1")
hudPrint("You have been punished!")
isPunished = true
end
end
end
if isPunished == false then
for i in ScaleAlcove2:containedItems() do
if i.name:sub(1,11) ~= "weightstone" then
hudPrint("There is an incorrect item in Alcove 2")
hudPrint("You have been punished!")
isPunished = true
end
end
end
if isPunished == false then
for i in ScaleAlcove3:containedItems() do
if i.name:sub(1,11) ~= "weightstone" then
hudPrint("There is an incorrect item in Alcove 3")
hudPrint("You have been punished!")
isPunished = true
end
end
end
if isPunished == false then
for i in ScaleAlcove4:containedItems() do
if i.name:sub(1,11) ~= "weightstone" then
hudPrint("There is an incorrect item in Alcove 4")
hudPrint("You have been punished!")
isPunished = true
end
end
end
-- check if all alcove total weights are equal
-- first the talley
local AW1 = 0
local AW2 = 0
local AW3 = 0
local AW4 = 0
local x = 0
if isPunished == false then
x = 0
for i in ScaleAlcove1:containedItems() do
x = i:getWeight()
AW1 = AW1 + x
end
hudPrint(""..AW1)
x = 0
for i in ScaleAlcove2:containedItems() do
x = i:getWeight()
AW2 = AW2 + x
end
hudPrint(""..AW2)
x = 0
for i in ScaleAlcove3:containedItems() do
x = i:getWeight()
AW3 = AW3 + x
end
hudPrint(""..AW3)
x = 0
for i in ScaleAlcove4:containedItems() do
x = i:getWeight()
AW4 = AW4 + x
end
hudPrint(""..AW4)
end
-- now the comparison
if isPunished == false then
if AW1 ~= AW2 then
hudPrint(""..AW1.." and "..AW2.." are not equal.")
--hudPrint("You have been punished.")
isPunished = true
end
end
if isPunished == false then
if AW1 ~= AW3 then
hudPrint("AW1 and AW3 are not equal.")
--hudPrint("You have been punished.")
isPunished = true
--[[elseif AW1 ~= AW4 then
hudPrint("AW1 and AW4 are not equal.")
--hudPrint("You have been punished.")
isPunished = true
elseif AW2 ~= AW3 then
hudPrint("AW2 and AW3 are not equal.")
--hudPrint("You have been punished.")
isPunished = true
elseif AW2 ~= AW4 then
hudPrint("AW2 and AW4 are not equal.")
--hudPrint("You have been punished.")
isPunished = true
elseif AW3 ~= AW4 then
hudPrint("AW3 and AW4 are not equal.")
--hudPrint("You have been punished.")
isPunished = true]]
end
end
-- and finally success
if isPunished == false then
hudPrint("All things are equal.")
hudPrint("You may pass!")
ScaleDoor1:open()
end
end
and the custom assetts are
cloneObject{
name = "weightstone1",
baseObject = "rock",
uiname = "Weight Stone 1",
weight = 1.9,
}
cloneObject{
name = "weightstone2",
baseObject = "rock",
uiname = "Weight Stone 2",
weight = 2.4,
}
cloneObject{
name = "weightstone3",
baseObject = "rock",
uiname = "Weight Stone 3",
weight = 2.6,
}
cloneObject{
name = "weightstone4",
baseObject = "rock",
uiname = "Weight Stone 4",
weight = 2.7,
}
cloneObject{
name = "weightstone5",
baseObject = "rock",
uiname = "Weight Stone 5",
weight = 3.1,
}
cloneObject{
name = "weightstone6",
baseObject = "rock",
uiname = "Weight Stone 6",
weight = 3.3,
}
cloneObject{
name = "weightstone7",
baseObject = "rock",
uiname = "Weight Stone 7",
weight = 3.4,
}
cloneObject{
name = "weightstone8",
baseObject = "rock",
uiname = "Weight Stone 8",
weight = 3.7,
}
cloneObject{
name = "weightstone9",
baseObject = "rock",
uiname = "Weight Stone 9",
weight = 4.3,
}
cloneObject{
name = "weightstone10",
baseObject = "rock",
uiname = "Weight Stone 10",
weight = 4.5,
}
cloneObject{
name = "weightstone11",
baseObject = "rock",
uiname = "Weight Stone 11",
weight = 5.1,
}
cloneObject{
name = "weightstone12",
baseObject = "rock",
uiname = "Weight Stone 12",
weight = 5.4,
}