How would I be able to compare the percentage of the event.value of local function sliderListener( event ) and local function sliderListener1( event ) and display an image based on which value is higher?
display.setStatusBar(display.HiddenStatusBar)
local widget = require(“widget”)
local composer = require(“composer”)
local scene = composer.newScene()
local background
local title
local aBtn
local pBtn
local xMid = display.contentWidth / 2
local yMid = display.contentHeight / 2
local percTxt
local percTxt1
local cell
function scene:create(event)
local sceneGroup = self.view
background = display.newImage(“plants.psd”)
background.x = display.contentWidth/2
background.y = display.contentHeight/2
sceneGroup: insert(background)
cell = display.newImage(“flaccid.png”)
cell.x = display.contentWidth/2
cell.y = 200
sceneGroup: insert(cell)
aBtn = widget.newButton{
defaultFile=“button.png”,
width = 274,
height = 172
}
aBtn.x = 137
aBtn.y = 1248
aBtn: addEventListener( “touch”, touchListener)
sceneGroup: insert(aBtn)
pBtn = widget.newButton{
width = 274,
height = 172
}
pBtn.x = 613
pBtn.y = 1248
pBtn: addEventListener( “touch”, touchListener)
sceneGroup: insert(pBtn)
percTxt = display.newText(“Cell concentration: 0%”, 200, 1137, 350, 300, native.systemFont, 30)
percTxt.text = “Cell concentration: 0%”
sceneGroup: insert(percTxt)
percTxt1 = display.newText(“Solution concentration: 0%”, 622, 1100, 300, 300, native.systemFont, 30)
percTxt1.text = “Solution concentration: 0%”
sceneGroup: insert(percTxt1)
local function sliderListener( event )
percTxt.text = "Cell concentration: " … event.value … “%”
end
local function sliderListener1( event )
percTxt1.text = "Solution concentration: " … event.value … “%”
end
local compare ()
if
local slider = widget.newSlider(
{
x = 160,
y = 1050,
width = 250,
value = 0,
listener = sliderListener
}
)
sceneGroup: insert(slider)
local slider1 = widget.newSlider(
{
x = 610,
y = 1050,
width = 250,
value = 0,
listener = sliderListener1
}
)
sceneGroup: insert(slider1)
end
function touchListener(event)
if (event.target == aBtn and event.phase == “began”) then
composer.gotoScene(“animals”)
end
if (event.target == pBtn and event.phase == “began”) then
composer.gotoScene(“plants”)
return true
end
end
function scene:show (event)
end
function scene:destroy(event)
local sceneGroup = self.view
composer.removeScene(“plants”, true)
sceneGroup = nil
end
function scene:hide(event)
end
scene: addEventListener( “create”, scene )
scene: addEventListener( “show”, scene )
scene: addEventListener( “hide”, scene )
scene: addEventListener( “destroy”, scene )
return scene