erichdusk Posted June 2, 2011 Share Posted June 2, 2011 That is, for a loaded image to key out on white. I've made this script (below), and it does the basic idea, but it's not quite what I want. I have an alternative script based on the blood resource that does key out, but it uses specific imgDims and I don't know how to express "all" in LUA. Also, that one's a real hog at the moment. One other question. How would I rewrite the dxDrawImage line to render a single random frame at a time, using setTimer to render the next frame? Thanks everyone. (BTW, I know the 0,0,0, line isn't necessary, but I couldn't figure out how to exclude it without the alpha turning into the address line.) ________________________________________________________________________________________________________ local rootElement = getRootElement() local screenWidth,screenHeight = guiGetScreenSize() local frame = {} frame[1] = "images/noise_1.png" frame[2] = "images/noise_2.png" frame[3] = "images/noise_3.png" frame[4] = "images/noise_4.png" frame[5] = "images/noise_5.png" frame[6] = "images/noise_6.png" frame[7] = "images/noise_7.png" frame[8] = "images/noise_8.png" frame[9] = "images/noise_9.png" frame[10] = "images/noise_10.png" frame[11] = "images/noise_11.png" frame[12] = "images/noise_12.png" frame[13] = "images/noise_13.png" frame[14] = "images/noise_14.png" frame[15] = "images/noise_15.png" frame[16] = "images/noise_16.png" frame[17] = "images/noise_17.png" frame[18] = "images/noise_18.png" frame[19] = "images/noise_19.png" frame[20] = "images/noise_20.png" frame[20] = "images/noise_21.png" frame[20] = "images/noise_22.png" frame[20] = "images/noise_23.png" frame[20] = "images/noise_24.png" frame[20] = "images/noise_25.png" frame[20] = "images/noise_26.png" frame[20] = "images/noise_27.png" frame[20] = "images/noise_28.png" frame[20] = "images/noise_29.png" frame[20] = "images/noise_30.png" function randomframe() dxDrawImage(0, 0, screenWidth, screenHeight, frame[math.random(#frame)], 0, 0, 0, tocolor (200, 200, 200, 5)) end addEventHandler("onClientRender",rootElement, randomframe) Link to comment
karlis Posted June 2, 2011 Share Posted June 2, 2011 (BTW, I know the 0,0,0, line isn't necessary, but I couldn't figure out how to exclude it without the alpha turning into the address line.) you did it right, it is necessary in case you want change color. and timer is also correct solution. do something like setTimer(function() randFrame=math.random(#frame) end,5000,0) --i set it change each 5sec and then just call this arg in the draw. Link to comment
erichdusk Posted June 2, 2011 Author Share Posted June 2, 2011 Something like this? I tried this, alternately using the setTimer as the first argument, but neither seemed to work. I'm probably missing something though, I'm pretty new to scripting. function randomframe() dxDrawImage(0, 0, screenWidth, screenHeight, frame[math.random(#frame)], 0, 190, 190, tocolor (200, 200, 200, 5)) setTimer(function()randFrame=math.random(#frame)end,5000,0) --i set it change each 5sec end addEventHandler("onClientRender",rootElement, randomframe) Link to comment
erichdusk Posted June 2, 2011 Author Share Posted June 2, 2011 Ok, I have the timer work, but there's another issue. How do I make the argument in dxdrawimage to render a single random frame at a time? SetTimer's working fine, but since the dxDrawImage still cycles through random frames as fast as it can retrieve them, it ends up creating a feedback loop. local screenWidth,screenHeight = guiGetScreenSize() local imgDims = guiGetScreenSize() local frame = {} frame[1] = "images/noise_1.png" frame[2] = "images/noise_2.png" frame[3] = "images/noise_3.png" frame[4] = "images/noise_4.png" frame[5] = "images/noise_5.png" frame[6] = "images/noise_6.png" frame[7] = "images/noise_7.png" frame[8] = "images/noise_8.png" frame[9] = "images/noise_9.png" frame[10] = "images/noise_10.png" frame[11] = "images/noise_11.png" frame[12] = "images/noise_12.png" frame[13] = "images/noise_13.png" frame[14] = "images/noise_14.png" frame[15] = "images/noise_15.png" frame[16] = "images/noise_16.png" frame[17] = "images/noise_17.png" frame[18] = "images/noise_18.png" frame[19] = "images/noise_19.png" frame[20] = "images/noise_20.png" frame[20] = "images/noise_21.png" frame[20] = "images/noise_22.png" frame[20] = "images/noise_23.png" frame[20] = "images/noise_24.png" frame[20] = "images/noise_25.png" frame[20] = "images/noise_26.png" frame[20] = "images/noise_27.png" frame[20] = "images/noise_28.png" frame[20] = "images/noise_29.png" frame[20] = "images/noise_30.png" function randomframe() dxDrawImage(0, 0, screenWidth, screenHeight, frame[math.random(#frame)], 0, 200, 200, tocolor (200, 200, 200, 5)) setTimer(randomframe,5000,0) end addEventHandler("onClientRender",rootElement, randomframe) Link to comment
AGENT_STEELMEAT Posted June 3, 2011 Share Posted June 3, 2011 Why not change the image every X number of frames? Link to comment
Castillo Posted June 3, 2011 Share Posted June 3, 2011 You are creating a new infinite timer on every render.... I think your code should look like this: local screenWidth,screenHeight = guiGetScreenSize() local imgDims = guiGetScreenSize() local frame = {} frame[1] = "images/noise_1.png" frame[2] = "images/noise_2.png" frame[3] = "images/noise_3.png" frame[4] = "images/noise_4.png" frame[5] = "images/noise_5.png" frame[6] = "images/noise_6.png" frame[7] = "images/noise_7.png" frame[8] = "images/noise_8.png" frame[9] = "images/noise_9.png" frame[10] = "images/noise_10.png" frame[11] = "images/noise_11.png" frame[12] = "images/noise_12.png" frame[13] = "images/noise_13.png" frame[14] = "images/noise_14.png" frame[15] = "images/noise_15.png" frame[16] = "images/noise_16.png" frame[17] = "images/noise_17.png" frame[18] = "images/noise_18.png" frame[19] = "images/noise_19.png" frame[20] = "images/noise_20.png" frame[20] = "images/noise_21.png" frame[20] = "images/noise_22.png" frame[20] = "images/noise_23.png" frame[20] = "images/noise_24.png" frame[20] = "images/noise_25.png" frame[20] = "images/noise_26.png" frame[20] = "images/noise_27.png" frame[20] = "images/noise_28.png" frame[20] = "images/noise_29.png" frame[20] = "images/noise_30.png" setTimer(function() randFrame=math.random(#frame) end,5000,0) function randomframe() dxDrawImage(0, 0, screenWidth, screenHeight, frame[randFrame], 0, 200, 200, tocolor (200, 200, 200, 5)) end addEventHandler("onClientRender",rootElement, randomframe) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now