Making more elements color PHOT

  • 12Me21
    22nd Jun 2017 Member 2 Permalink

    A few old elements will change the color of photons that reflect off of them, but it seems like this hasn't been updated for a long time.
    I think this should work with all elements.

  • Ligan
    26th Jun 2017 Member 0 Permalink

    I agree. Also ICE, BUBW, LN2 and gasses should be transparent

  • jacob1
    16th Jul 2017 Developer 1 Permalink
    I added one for POLO.

    The main issue is that there's not many photon colors to work with ... the photon color format is extremely limited. I see what it was going for, but maybe it could have allowed a few more colors besides yellow, cyan, magenta, and white ...

    I made a script to generate all the colors, which I believe is correct (embedded in save with my mod). Pretty much everything comes out to duplicate RGB values
  • docRoboRobert
    16th Jul 2017 Member 0 Permalink

    I agree. PLNT should remove green colour from photons.   <--- Don't look at this, I'm stupid...

     

    I agree. PLNT should "eat" all photon's colours instead of green.

    Edited 7 times by docRoboRobert. Last: 16th Jul 2017
  • Alexwall
    16th Jul 2017 Member 0 Permalink

    @jacob1 (View Post)

     can we have this script

  • Mrprocom
    16th Jul 2017 Moderator 1 Permalink
    @ajloveslily (View Post)
    It automatically gets added to the Powder Toy directory when you open the save in jacob1's mod. Here it is anyway:
    local xPos, yPos = 100, 100
    local xPos2, yPos2 = 300, 100
    local rgb = {}

    local function makebits(color, num, offset)
    local bits = bit.lshift(2^num-1, offset)
    return bit.bor(color, bits)
    end

    local function makephot(x, y, color)
    local i = sim.partCreate(-1, x, y, tpt.el.phot.id)
    if i ~= -1 then
    sim.partProperty(i, sim.FIELD_CTYPE, color)
    end
    end

    local function seenColor(r, g, b)
    if not rgb[r] then
    rgb[r] = {}
    end
    if not rgb[r][g] then
    rgb[r][g] = {}
    end
    if not rgb[r][g][b] then
    rgb[r][g][b] = true
    return false
    end
    return true
    end

    local function getRGB(color)
    local colr, colg, colb = 0, 0, 0
    for i = 0,11 do
    colr = colr + bit.band(bit.rshift(color, i+18), 0x1)
    colg = colg + bit.band(bit.rshift(color, i+9), 0x1)
    colb = colb + bit.band(bit.rshift(color, i), 0x1)
    end
    local multiplier = math.floor(624 / ( colr + colg + colb + 1))
    colr = colr * multiplier
    colg = colg * multiplier
    colb = colb * multiplier
    if colr > 255 then colr = 255 end
    if colg > 255 then colg = 255 end
    if colb > 255 then colb = 255 end

    -- PHOT colors are so screwed up
    colr = bit.rshift(255*colr + 255*colr, 8)
    cobg = bit.rshift(255*colg + 255*colb, 8)
    colb = bit.rshift(255*colb + 255*colb, 8)
    if colr > 255 then colr = 255 end
    if colg > 255 then colg = 255 end
    if colb > 255 then colb = 255 end

    return colr, colg, colb
    end

    for r = 0,9 do
    for b = 0,9 do
    for g = 0,6 do
    for y = 0,3 do
    for c = 0,3 do
    local color = 0
    color = makebits(color, r, 0)
    color = makebits(color, y, 9)
    color = makebits(color, g, 12)
    color = makebits(color, c, 18)
    color = makebits(color, b, 21)
    local rgbR, rgbG, rgbB = getRGB(color)
    if not seenColor(rgbR, rgbG, rgbB) then
    makephot(xPos2, yPos2, color)
    if xPos2 > 400 then
    xPos2 = 300
    yPos2 = yPos2 + 1
    end
    xPos2 = xPos2 + 1
    end
    makephot(xPos, yPos, color)
    if xPos > 200 then
    xPos = 100
    yPos = yPos + 1
    end
    xPos = xPos + 1
    end
    end
    end
    end
    end


    Edit: I made a script that uses most of @jacob1's code to assign different colours to newly-placed photons: https://starcatcher.us/scripts/#122
    Edited 2 times by Mrprocom. Last: 16th Jul 2017
  • Alexwall
    17th Jul 2017 Member 0 Permalink
  • ttf236
    17th Jul 2017 Banned 0 Permalink
    This post is hidden because the user is banned
    Edited once by ttf236. Last: 17th Jul 2017
  • tptquantum
    17th Jul 2017 Member 0 Permalink
    This post has been removed: replying to spam