Jump to content

Help with something


Victor214

Recommended Posts

hey guys, I have a question. I'm supposed to do a script that every 24 hours (00:00) of real life it starts a function (and I've already made it). In the function that will be started, I need to get 2 random values, one from 0 to 23 and other from 1 to 5, I also did it (0 to 23 is the real time that a function will be started and 1 to 5 is which function will be started, there are 5 functions). So, after that, I needed to do almost 400 lines of "if ( hour == 0 and event == 101 ) then meteor end" to preview every possibilitie, so I'd like to ask you, is there any way to reduce this ammount of lines? It's really confused to explain and to read as well, so I'll put the script(download because it's 400 lines):

http://www.sendspace.com/file/n51n4c

Link to comment

You can use a table for example:

  
function Test() 
local Table = {{1--[[Hour]], 10--[[Event]]}, {2, 20}, {3, 30}} -- etc .. 
for data, value in ipairs(Table) do 
if Hour == value[1] and Event == value[2] then 
-- code 
end 
end 
  

Don't know if works just must be like this. If I understood you right :D.

Link to comment
    if ( hour == 0 and event == 101 ) then 
    meteor  
    end 
    if ( hour == 0 and event == 102 ) then 
    zombie 
    end 
    if ( hour == 0 and event == 103 ) then 
    alien 
    end 
    if ( hour == 0 and event == 104 ) then 
    flood 
    end 
    if ( hour == 0 and event == 105 ) then 
    sun 
    end 

You're calling functions wrong here.

Link to comment

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...