Log In  


so today i made this
use it as you want guys
also maybe it's not token-efficient but
i'll leave it up to you

function randprob_from(l)
	--the function expects an
	--array of tables like these:
	--{p=0.5,v='item name'}

	--a "p" value between 0 and 1
	--and a "v" value.

	--"p" is propability of the
	--"v" value being returned

	local lim=1
	local value=rnd()
	for pos in all(l) do
		highlimit=lim
		lim-=pos.p
		lowlimit=lim
		if value<highlimit
		and value>=lowlimit then
			return pos.v
		end
	end
end

Cart #pipugozape-1 | 2023-05-27 | Code ▽ | Embed ▽ | No License




[Please log in to post a comment]