antiblock
https://i.imgur.com/aJ17bf7.gif
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
Witness

[Dúvida]Valores Aleratorios Como Tabelas

5 posts in this topic

tipo eu tenho isso

function dword()
	return {
	       100,
		   500,
		   1000,
		   6000,


	}
end

agora quero que isso print um valor aleratório da tabela alguem sabe como se faz?

 

 

 

 

 

Share this post


Link to post
Share on other sites
antiblock
diamwall


function dword()

local tbl = {100, 500, 1000, 6000}

math.randomseed(os.time())

return tbl[math.random(#tbl)]

end

print(dword())

Share this post


Link to post
Share on other sites
function dword()
	local tbl = {100, 500, 1000, 6000}

	math.randomseed(os.time())
	return tbl[math.random(#tbl)]
end

print(dword())

retorna sempre 6000 assim

Share this post


Link to post
Share on other sites

cba8aa86fd.png

Share this post


Link to post
Share on other sites

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
Sign in to follow this