Jump to content

let random pictures appear and disappear


trustno1

Recommended Posts

Posted

So what I want to do is:

Let random pictures appear on the screen for 1 single frame continuous.

Something isn't working though and Debug doesn't show any errors.

I'm not a very experienced scripter so it would be cool if you could help me out on this.

  
local rootElement = getRootElement() 
local screenWidth,screenHeight = guiGetScreenSize() 
  
local frame = {} 
frame[1] = "pic/01.png" 
frame[2] = "pic/02.png" 
frame[3] = "pic/03.png" 
frame[4] = "pic/04.png" 
frame[5] = "pic/05.png" 
frame[6] = "pic/06.png" 
frame[7] = "pic/07.png" 
frame[8] = "pic/08.png" 
frame[9] = "pic/09.png" 
frame[10] = "pic/10.png" 
frame[11] = "pic/11.png" 
frame[12] = "pic/12.png" 
frame[13] = "pic/13.png" 
frame[14] = "pic/14.png" 
frame[15] = "pic/15.png" 
frame[16] = "pic/16.png" 
frame[17] = "pic/17.png" 
frame[18] = "pic/18.png" 
frame[19] = "pic/19.png" 
frame[20] = "pic/20.png" 
frame[21] = "pic/21.png" 
frame[22] = "pic/22.png" 
frame[23] = "pic/23.png" 
frame[24] = "pic/24.png" 
frame[25] = "pic/25.png" 
frame[26] = "pic/26.png" 
frame[27] = "pic/27.png" 
frame[28] = "pic/28.png" 
frame[29] = "pic/29.png" 
frame[30] = "pic/30.png" 
frame[31] = "pic/31.png" 
frame[32] = "pic/32.png" 
frame[33] = "pic/33.png" 
frame[34] = "pic/34.png" 
frame[35] = "pic/35.png" 
frame[36] = "pic/36.png" 
frame[37] = "pic/37.png" 
frame[38] = "pic/38.png" 
frame[39] = "pic/39.png" 
frame[40] = "pic/40.png" 
frame[41] = "pic/41.png" 
frame[42] = "pic/42.png" 
frame[43] = "pic/43.png" 
frame[44] = "pic/44.png" 
frame[45] = "pic/45.png" 
frame[46] = "pic/46.png" 
frame[47] = "pic/47.png" 
frame[48] = "pic/48.png" 
frame[49] = "pic/49.png" 
frame[50] = "pic/50.png" 
frame[51] = "pic/51.png" 
frame[52] = "pic/52.png" 
frame[53] = "pic/53.png" 
  
  
  
  
  
function randomframe() 
local randF = math.random (#frame) 
randx = dxDrawImage (0, 0, screenWidth, screenHeight, 'randF') 
end 
function HandleTheRendering ( ) 
    addEventHandler("onClientRender",rootElement, randomframe)  
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 
setTimer(HandleTheRendering, 50, 0) 
  

meta.xml

  

Posted
local randF = math.random (#frame) 
function randomize() 
    randF = math.random (#frame) 
end 
function HandleTheRendering ( ) 
    dxDrawImage (0, 0, screenWidth, screenHeight, "pic/"..randF..".png") 
end 
addEventHandler("onClientRender",rootElement, HandleTheRendering ) 
setTimer(HandleTheRendering, 1000, 0) -- why was the timer at 50? that's very very fast. 

Try that. And rename your pictures 01.png to 1.png, same with all the others until 09.png.

Posted
  
local rootElement = getRootElement() 
local screenWidth,screenHeight = guiGetScreenSize() 
  
local frame = {} 
frame[1] = "pic/01.png" 
frame[2] = "pic/02.png" 
frame[3] = "pic/03.png" 
frame[4] = "pic/04.png" 
frame[5] = "pic/05.png" 
frame[6] = "pic/06.png" 
frame[7] = "pic/07.png" 
frame[8] = "pic/08.png" 
frame[9] = "pic/09.png" 
frame[10] = "pic/10.png" 
frame[11] = "pic/11.png" 
frame[12] = "pic/12.png" 
frame[13] = "pic/13.png" 
frame[14] = "pic/14.png" 
frame[15] = "pic/15.png" 
frame[16] = "pic/16.png" 
frame[17] = "pic/17.png" 
frame[18] = "pic/18.png" 
frame[19] = "pic/19.png" 
frame[20] = "pic/20.png" 
frame[21] = "pic/21.png" 
frame[22] = "pic/22.png" 
frame[23] = "pic/23.png" 
frame[24] = "pic/24.png" 
frame[25] = "pic/25.png" 
frame[26] = "pic/26.png" 
frame[27] = "pic/27.png" 
frame[28] = "pic/28.png" 
frame[29] = "pic/29.png" 
frame[30] = "pic/30.png" 
frame[31] = "pic/31.png" 
frame[32] = "pic/32.png" 
frame[33] = "pic/33.png" 
frame[34] = "pic/34.png" 
frame[35] = "pic/35.png" 
frame[36] = "pic/36.png" 
frame[37] = "pic/37.png" 
frame[38] = "pic/38.png" 
frame[39] = "pic/39.png" 
frame[40] = "pic/40.png" 
frame[41] = "pic/41.png" 
frame[42] = "pic/42.png" 
frame[43] = "pic/43.png" 
frame[44] = "pic/44.png" 
frame[45] = "pic/45.png" 
frame[46] = "pic/46.png" 
frame[47] = "pic/47.png" 
frame[48] = "pic/48.png" 
frame[49] = "pic/49.png" 
frame[50] = "pic/50.png" 
frame[51] = "pic/51.png" 
frame[52] = "pic/52.png" 
frame[53] = "pic/53.png" 
  
function randomframe() 
  dxDrawImage(0, 0, screenWidth, screenHeight, frame[math.random(#frame)]) 
end 
addEventHandler("onClientRender",rootElement, randomframe) 
  

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...