Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- nucular's Particle Monitor III.I
- -- Changes III.I
- -- - Fixed rounding
- -- Changes III
- -- - Works on zoom mode!!
- -- - Shows temperature in °C and in K!
- -- - Draws inside a dark box.
- -- - You can set the precision of temp, vx and vy.
- -- Settings
- -- Press this key to toggle the monitor.
- local key = 283 -- F2
- local modifier = 0 -- Nothing
- -- And this key to switch between verbose and compact mode.
- local ev_key = 284 -- F3
- local ev_modifier = 0 -- Nothing
- local precision = 2 -- Decimal places at temp, vx, vy ...
- -------------------------------------
- local show = true
- local show_everything = true
- local rectHeight = 137
- local function lk(nr)
- -- try to find out the name of an element
- local is_el, el = pcall(tpt.element, nr)
- if is_el == true then
- return el
- else
- return ""
- end
- end
- local function round(nr)
- local c = math.pow(10, precision)
- return tostring(math.floor(nr * c) / c)
- end
- local function draw()
- local x = tpt.mousex
- local y = tpt.mousey
- local x, y = sim.adjustCoords(x,y)
- local id = tpt.get_property('id', x, y)
- local str = x .. "," .. y
- if show_everything == true then
- local typ = sim.partProperty(id, 'type')
- local ctype = sim.partProperty(id, 'ctype')
- local temp = round(sim.partProperty(id, 'temp'))
- local life = sim.partProperty(id, 'life')
- local tmp = sim.partProperty(id, 'tmp')
- str = str .. "\n#" .. id
- .. "\ntype: " .. typ .. " " .. lk(typ)
- .. "\nctype: " .. ctype .. " " .. lk(ctype)
- .. "\ntemp: " .. temp-273.15 .. " C (" .. temp .. " K)"
- .. "\nlife: " .. life
- .. "\ntmp: " .. tmp .. " " .. lk(tmp)
- end
- local tmp2 = sim.partProperty(id, 'tmp2')
- local vx = round(sim.partProperty(id, 'vx'))
- local vy = round(sim.partProperty(id, 'vy'))
- local dcolour = sim.partProperty(id, 'dcolour')
- str = str .. "\ntmp2: " .. tmp2 .. " " .. lk(tmp2)
- .. "\nvx: " .. vx
- .. "\nvy: " .. vy
- .. "\ndcolour: #" .. string.format("%X", dcolour)
- gfx.fillRect(12,27,gfx.textSize(str)+8,rectHeight,0,0,0,127)
- gfx.drawText(16,32,str, 200, 200, 200)
- end
- local function safedraw()
- if show then
- pcall(draw)
- end
- end
- local function toggle()
- if show == false then
- show = true
- else
- show = false
- end
- end
- local function hotkey(keystr, keynum, mod, evt)
- if keynum == key and mod == modifier and evt == 1 then
- toggle()
- end
- if keynum == ev_key and mod == ev_modifier and evt == 1 then
- if show_everything == true then
- show_everything = false
- rectHeight = 65
- else
- show_everything = true
- rectHeight = 137
- end
- end
- end
- tpt.register_keypress(hotkey)
- tpt.register_step(safedraw)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement