tostring produces non equal strings on script start
complete
WolfGang Senizen
Output of tostring that should be the same are not equal if done outside of "events"
function test()
if tostring(5) == tostring(5) then
ll.Say(0,"EQUAL")
else
ll.Say(0,"NOT EQUAL")
end
end
test()
touch_start = test
Says
NOT EQUAL
in chat on start, but EQUAL
on touchRunning luau locally this
print(`{tostring(5) == tostring(5)}`)
prints
true
String comparison in general works
local last_msg = ""
listen = function(chan, name, id, msg)
if msg == last_msg then
ll.Say(0, "Stop Repeating Yourself")
end
last_msg = msg
end
ll.Listen(0,"","","")
Says
Stop Repeating Yourself
in local if you say the same thing twiceA more comprehensive script that started this adventure, note that it works fine in the touch event
function test()
ll.Say(0,"============================")
local own1 = ll.GetOwner()
local own2 = ll.GetOwner()
local comp = own1 == own2
if comp then
ll.Say(0, `UUID EQUAL: {comp}`)
else
ll.Say(0, `UUID NOT EQUAL: {comp}`)
end
if own1 == own2 then
ll.Say(0, `UUID EQUAL`)
else
ll.Say(0, `UUID NOT EQUAL`)
end
ll.Say(0, tostring(own1))
ll.Say(0, tostring(own2))
own1 = tostring(own1)
own2 = tostring(own2)
comp = own1 == own2
if comp then
ll.Say(0, `STRING EQUAL: {comp}`)
else
ll.Say(0, `STRING NOT EQUAL: {comp}`)
end
if own1 == own2 then
ll.Say(0, `STRING EQUAL`)
else
ll.Say(0, `STRING NOT EQUAL`)
end
ll.Say(0, own1)
ll.Say(0, own2)
ll.Say(0,"============================")
end
test()
ll.Sleep(2.0)
test()
touch_start = test
Log In
Signal Linden
complete
Fixed in the most recent release. Thanks for the report and repro scripts!
Thunder Rahja
Workaround: Don't create the same string twice in the same line.
local testString = tostring(5)
function test()
if tostring(5) == testString then
ll.Say(0,"EQUAL")
else
ll.Say(0,"NOT EQUAL")
end
end
test()
touch_start = test
Signal Linden
in progress
Ruby Maelstrom
Have been doing some further investigation:
llGetOwner()==llGetOwner evaluates to TRUE inside of:
event functions such as touch_start & sensor
coroutines
inside of a user-defined function, called from inside of an event or coroutine
ll.GetOwner()==ll.GetOwner() evaluates to FALSE when:
In the base of a script, outside of a function
Inside of a user-defined function, called from the base of the script
coroutine.resume(detected)
comparison2 = ll.GetOwner() == ll.GetOwner()
ll.OwnerSay("Global: " .. tostring(comparison2))
dummy()
Results in:
Coroutine: true
Global: false
Dummy Function: false