Reputation: 85
So I have this piece of code
for i=1, #result, 1 do
local vehicleProps = json.decode(result[i].vehicle)
print(vehicleProps.plate)
print(plate)
if vehicleProps.plate == plate then
found = true
print(found)
break
end
print(found)
end
The output I get is
UCF 804
864539
false
65507
864539
false
864539
864539
false
I am fairly new to Lua, but it is pretty simple, yet I cannot understand why when vehicleProps.plate is equal to plate, the code returns false? Is there any way to check if two values are the same? I would appreaciate any type of help here.
Output for user: hjpotter92
2162899082 417849 string string false
QBW 339 417849 string string false
27538 417849 string string false
UCF 804 417849 string string false
417849 417849 string string false
65507 417849 string string false
864539 417849 string string false
9703143430 417849 string string false
Upvotes: 4
Views: 1511
Reputation: 85
function all_trim(s)
return s:match( "^%s*(.-)%s*$" )
end
if all_trim(vehicleProps.plate) == all_trim(plate) then
Edited my code to be as follows, Looks like there was a space in there afterall, thank you everybody for trying to help
Upvotes: 1