Can't compare the same value in two different tables.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Can't compare the same value in two different tables.

Post by Zeliarden »

This is the tables you seek to compare. I hope this helps

Code: Select all

function love.update(dt)
	blocks.update()
	createSelectedTable()
	--if answer[3] == complexRadicalsI[43][3] then 
	if answer[3] == complexRadicalsI[43][1] then 
			pruebaEstado="works"
	end
end

function love.draw()
	blocks.draw()
	love.graphics.print(complexRadicals[43][2],0,0,0,0.4)
	love.graphics.print("the first character is shown when I'm not setting it as a string",40,0,0,0.4)
--	love.graphics.print("first kanji compared "..tostring(complexRadicals[43][#complexRadicals[43]]), 0, 20,0,0.4)
	love.graphics.print("first kanji compared "..tostring(complexRadicals[43][1][3]), 0, 20,0,0.4)
	love.graphics.print("second kanji compared "..tostring(answer[3]), 0, 40,0,0.4)
	love.graphics.print(pruebaEstado, 0, 120,0,0.4)
end
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: Can't compare the same value in two different tables.

Post by scissors61 »

Thanks @Zeliarden, it says it works, I can compare the values!, but I'm lost lol. So, the position is backward in love.update, but in love.graphics is in the order that is written in the components file, it seems... I'm trying to see the logic of this to continue with the code. Oh, I see that I made a mistake in the code I sent with complexRadicalsI[43][3], it should be complexRadicals[43][#complexRadicals[43]] or complexRadicals[43][2], that is the position of 疔 and not "一" , "亅" , "疔" that should be complexRadicals[43][1], but update sees it as 疔.

Edit: @Zeliarden, I see, you used complexRadicalsI, an index that I created to try as a solution to the problem of the for in pairs loop not working. But I tried complexRadicalsI[43] only and not as you suggested complexRadicalsI[43][1], so this that you pointed is a solution. I still don't know why complexRadicals[43][2][1] nor the for in pairs loop don't work, but with this I can keep working.

Next time I'll try to simplify the problem more, thanks to all m(_ _)m
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests