Background edit

  • kingcute50
    18th Aug 2012 Member 0 Permalink

    My scripts: http://pastebin.com/uBfpvKgr

    Can you explain why this doesn't work?

  • MasterMind555
    18th Aug 2012 Member 0 Permalink

    Let's debug this together:

    Did it give you any errors? Those are rather helpful when you are trying to know why your program doesn't work.

    > Apparently, it didn't

     

    Okay, then let's see what is executed first when the file is ran.

    >  "tpt.register_step(blah)"

     

    So that registers the function "blah" to be executed constantly, let's see what that function does

    > "dofile("bgEdit.lua")"

     

    The function 'blah' executes our file again, it would be much wiser to create a function to do what we want to do, and then register it or just call it.

     

    So it would give us 

     

     

     

    function blah()

        for x = 50,160 do

            for y = 70,180 do

                tpt.drawpixel(x,y,math.random(0,255),math.random(0,255),math.random(0,255))

            end

        end

    end

     

    tpt.register_step(blah)

     

     

    This makes the code much simpler to use and to debug.

     

    Also, you don't explain what exactly doesn't work.

  • kingcute50
    19th Aug 2012 Member 0 Permalink

    Oh nevermind.

    The tpt.register_step(blah) part was missing.

    Sorry about that but thanks for the tips in debugging.

  • jacob1
    19th Aug 2012 Developer 0 Permalink

    --kingcute50 in Powder Toy :D nvm
    --roblox username: king2218
    --very simple background editing in tpt
    function blah()
    tpt.drawtext(200,200,"Edited Background!",math.random(0,255),math.random(0,255),math.random(0,255))
    for x = 50,160 do
    for y = 70,180 do
    tpt.drawpixel(x,y,math.random(0,255),math.random(0,255),math.random(0,255))
    end
    end
    end
    tpt.register_step(blah)


    This will work, you only need to make the area larger to cover more of the screen. You were trying to call dofile everyframe, and then re-register a step too. Once you register a step, it will be called every frame, you don;t have to do anything extra.
  • kingcute50
    19th Aug 2012 Member 0 Permalink

    Just one more question,

    What is the length and the width of the screen in tpt?

  • jacob1
    19th Aug 2012 Developer 0 Permalink
    The width is 611 (628 total), and the height is 383 (423 total), depending on if you want to affect the entire screen, or just the simulation area.
  • kingcute50
    19th Aug 2012 Member 0 Permalink

    Thanks for that.

     

    I made something:

    function blah()
    	for x = -3,3 do
    		for y = -3,3 do
    			tpt.drawpixel(tpt.mousex + x,tpt.mousey + y,255,255,0)
    		end
    	end
    end
    
    tpt.register_step(blah)
    



    It follows the mouse. XD