Page 1 of 1

UO.Random

Posted: 2006-07-16 06:00:58
by Umuri
This code is supposed to randomly summon an npc from 0000 to 1fff. The problem is, when run, it gives the same "random" number to each of the j arrays. I have a workaround using random16 random17 random18 and throwing out excess numbers, but is there a way to make it work with 3 calls for the same random set of numbers within a same function?



Code: Select all

sub randsummon()
var i = uo.random(2)
var l = 1
var m = str(i)
DIM j[3]
j[1] = uo.random(16)
j[2] = uo.random(16)
j[3] = uo.random(16)
// uo.print("Number: " + str(j[1]) + str(j[2]) + str(j[3]) ) Bugtesting
while l < 4
if j[l] == 10 then
j[l] = 'a'
end if
if j[l] == 11 then
j[l] = 'b'
end if
if j[l] == 12 then
j[l] = 'c'
end if
if j[l] == 13 then
j[l] = 'd'
end if
if j[l] == 14 then
j[l] = 'e'
end if
if j[l] == 15 then
j[l] = 'f'
end if
if j[l] <= 9 then
j[l] = str(j[l])
end if
m = m + j[l]
l = l + 1
wend
uo.print("Summoning:" + m)
uo.say(".addnpc " + m)
end sub