[solved] This is very frustrating!
Posted: Sun Feb 03, 2013 1:16 am
I am begining to think there may be some serious flaws in either the editor, or Lua or Grimrock, or my computer.
I am trying to make sure the weight in 4 alcoves is equal. I went back to spaghetti code because I know I can do it that way and haven't figured out this crazy LUA language. And this should work.
First I get the weights from each alcove and add them up. Working fine through multipe tests.
Then I also print them out to confirm the are correct. Fine.
Then I compare to see if they are not equal, and hudPrint the results
The results show "9.5 and 9.5 are not equal!" In what world is 9.5 and 9.5 not equal? (btw not the real number in case anyone play my mod)
and the kicker is, without doing anything different it worked...once.
This is getting so frustrating.
Ok, rant off now.
I am trying to make sure the weight in 4 alcoves is equal. I went back to spaghetti code because I know I can do it that way and haven't figured out this crazy LUA language. And this should work.
Code: Select all
-- 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
endThen I also print them out to confirm the are correct. Fine.
Then I compare to see if they are not equal, and hudPrint the results
The results show "9.5 and 9.5 are not equal!" In what world is 9.5 and 9.5 not equal? (btw not the real number in case anyone play my mod)
and the kicker is, without doing anything different it worked...once.
This is getting so frustrating.
Ok, rant off now.