Jump to content

[Question] Comparing strings to change dxDrawText?


Recommended Posts

Hello.

 

So, I'm using [this script right here].

 

I've edited it just a little bit to actually show the vehicle's RPM and amount of gears, yet I'd like to make one more change and... I'm stuck a little, because I've no idea what kind of "if condition" should I use. Below is an example of a single condition where I'm comparing the amount of gears to the maximum amount of gears and if it's the same, then the dxDrawText color changes from black to red, works.

if RESKINNED_DEBUG and vehicle == myVehicle then
        if(tostring(data.gear) == tostring(#gearRatios)) then
	-- maximum amount of gears
        dxDrawText(tostring(#gearRatios), (screenW * 0.8562) - 1, (screenH * 0.8148) - 1, (screenW * 0.9031) - 1, (screenH * 0.8380) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(#gearRatios), (screenW * 0.8562) + 1, (screenH * 0.8148) - 1, (screenW * 0.9031) + 1, (screenH * 0.8380) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(#gearRatios), (screenW * 0.8562) - 1, (screenH * 0.8148) + 1, (screenW * 0.9031) - 1, (screenH * 0.8380) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(#gearRatios), (screenW * 0.8562) + 1, (screenH * 0.8148) + 1, (screenW * 0.9031) + 1, (screenH * 0.8380) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	-- gears
	dxDrawText(tostring(data.gear), screenW * 0.8562, screenH * 0.8148, screenW * 0.9031, screenH * 0.8380, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	else
	dxDrawText(tostring(data.gear), (screenW * 0.8562) - 1, (screenH * 0.8148) - 1, (screenW * 0.9031) - 1, (screenH * 0.8380) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(data.gear), (screenW * 0.8562) + 1, (screenH * 0.8148) - 1, (screenW * 0.9031) + 1, (screenH * 0.8380) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(data.gear), (screenW * 0.8562) - 1, (screenH * 0.8148) + 1, (screenW * 0.9031) - 1, (screenH * 0.8380) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(data.gear), (screenW * 0.8562) + 1, (screenH * 0.8148) + 1, (screenW * 0.9031) + 1, (screenH * 0.8380) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
	dxDrawText(tostring(data.gear), screenW * 0.8562, screenH * 0.8148, screenW * 0.9031, screenH * 0.8380, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
        end
end

 

And here's the code I'm using to show the vehicle's RPM:

dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) + 1, (screenH * 0.6759) - 1, (screenW * 0.9031) + 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) + 1, (screenW * 0.9031) - 1, (screenH * 0.6991) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) + 1, (screenH * 0.6759) + 1, (screenW * 0.9031) + 1, (screenH * 0.6991) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
dxDrawText(string.format("%4d", tostring(rpm)), screenW * 0.8562, screenH * 0.6759, screenW * 0.9031, screenH * 0.6991, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)

It was literally added after the condition I pasted above. Unfortunately the further, the worse. I've been trying to make completely random conditions such like

if(string.format("%4d", tostring(rpm)) < string.format("%4d", tostring(rpm))-500) then
	dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
...
else
	dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
...
end

but... nah, they don't seem to work. What should I do and... is it even possible to compare one string to another and just check whether the value of this string is less than, for example 500, or not?

Edited by Linux_Shines
sigh
Link to comment
  • Linux_Shines changed the title to [Question] Comparing strings to change dxDrawText?
  • !#NssoR_) locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...