Lua Challenge: the Catastrophes plugin
#11
I'm open to everything, but one thing I'll do for sure is acid rain (it's not a natural disaster but I want to do it)
Reply
Thanks given by:
#12
One question: When using ForEachPlayer, what players are looped first? Is it random?
If it isnt, anyway to choose a random player fastly and easily?
Also, is there anyway to get a random x, y, z in a loaded chunk without loading it? (Only random between loaded chunks)
Reply
Thanks given by:
#13
I'm guessing it's in the order the player's joined.

What you can do is get the number of players, create a random number between 0 and that number, and then take player <nr> from that number.
-- NumPlayers is for example 10
local RandomPlayer = math.random(NumPlayers)
local CurrentPlayer = 0
World:ForEachPlayer(
   function()
      CurrentPlayer = CurrentPlayer + 1
      if (CurrentPlayer == RandomPlayer) then
         --- Do things
         return true -- we did what we wanted with the player
      end
   end
)

Get a random x, y, z in a loaded chunk without loading it? Whut? Assuming you meant unloaded chunk. Can't you just use:
local X = math.random(15)
local Y = math.random(255)
local Z = math.random(15)
Reply
Thanks given by: tonibm19
#14
(05-22-2015, 02:46 AM)NiLSPACE Wrote:
Get a random x, y, z in a loaded chunk without loading it? Whut? Assuming you meant unloaded chunk. Can't you just use:
local X = math.random(15)
local Y = math.random(255)
local Z = math.random(15)
I meant getting random coordinates only inside loaded chunks
Reply
Thanks given by:
#15
The only method that might work is cWorld:TryGetHeight. With that you can check if a chunk is loaded.
Reply
Thanks given by:
#16
I suppose it's kinda working:
[Image: fd1318402c.jpg]

TOO MUCH!
[Image: 93d2f7d0f0.jpg]
Reply
Thanks given by: tonibm19
#17
There's currently no cWorld:ForEachChunk() API function which would help you, but it shouldn't be too difficult to add it.
Reply
Thanks given by: Serial
#18
Apache License 2.0 is allowed right?
Reply
Thanks given by:
#19
That moment when you realize you are really cruel for the villagers:
[Image: e1f05996dc.jpg]

It really killed the performance though:
[Image: 7576860bde.png]

I'll have to randomize it, but it looks less good if I do that Sad

Btw, I had had a question about the license above here Wink
Reply
Thanks given by: Serial
#20
So, we need luajit! Smile
Reply
Thanks given by:




Users browsing this thread: 5 Guest(s)