--afficherla quantité de carburant dans un ecran: screen.clear() local tmp = math.floor(container_0.getItemsMass()*10)/10 screen.setText(0,0,10, "fuel:" .. tmp) --Cuve carburant svg screen.clear() local strHtml -- variable qui va contenir l'html/svg local fuel1 = math.floor ( ( container_1.getItemsMass()/1750)/8*100 ) -- % de fuel local fuel2 = math.floor ( ( container_2.getItemsMass()/1750)/8*100 ) -- % de fuel local fuel3 = math.floor ( ( container_3.getItemsMass()/1750)/8*100 ) -- % de fuel local fuel4 = math.floor ( ( container_4.getItemsMass()/800)/8*100 ) -- % de fuel local fuel5 = math.floor ( ( container_5.getItemsMass()/800)/8*100 ) -- % de fuel local fuel6 = math.floor ( ( container_6.getItemsMass()/800)/8*100 ) -- % de fuel function displayFuel(fuelQuantity) local freturn = [[<div class="gauge"> <svg viewBox="0 0 20 100"> <rect x="0" y="0" rx="8" ry="8" width="20" height="100" style="fill:white;fill-opacity:1;stroke:black;stroke-width:1;opacity:1" /> <rect x="0" y="0" rx="8" ry="8" width="20" height="]] .. fuelQuantity .. [[" style="fill:orange;opacity:1;stroke:black;stroke-width:1" transform="translate(0,100), rotate(180 10 0)"/> </svg> <span>]] .. fuelQuantity .. [[</span> </div>]] return freturn end strHtml = [[<html> <head> <style type="text/css"> body{ background-color: #000; } .gauges_container{ display: flex; height: 80vh; } .gauges_container .gauge{ position: relative; height: 100%; width: calc(100vw / 6); } .gauges_container .gauge svg{ position: absolute; height: 100%; width: 100%; } .gauges_container .gauge span{ text-align: center; font-size: 10vh; color: #fff; position: absolute; bottom: -10vh; width: 100%; } </style> </head> <body> <body> <div class="gauges_container">]] strHtml = strHtml .. displayFuel(fuel1) strHtml = strHtml .. displayFuel(fuel2) strHtml = strHtml .. displayFuel(fuel3) strHtml = strHtml .. displayFuel(fuel4) strHtml = strHtml .. displayFuel(fuel5) strHtml = strHtml .. displayFuel(fuel6) strHtml = strHtml .. [[ </div> </body> </body> </html>]] screen.setRawHTML(strHtml)
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more