Lua Challenge: the Catastrophes plugin - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Lua Challenge: the Catastrophes plugin (/thread-1972.html) |
RE: Lua Challenge: the Catastrophes plugin - tonibm19 - 05-22-2015 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) RE: Lua Challenge: the Catastrophes plugin - tonibm19 - 05-22-2015 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) RE: Lua Challenge: the Catastrophes plugin - NiLSPACE - 05-22-2015 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) RE: Lua Challenge: the Catastrophes plugin - tonibm19 - 05-22-2015 (05-22-2015, 02:46 AM)NiLSPACE Wrote:I meant getting random coordinates only inside loaded chunks RE: Lua Challenge: the Catastrophes plugin - NiLSPACE - 05-22-2015 The only method that might work is cWorld:TryGetHeight. With that you can check if a chunk is loaded. RE: Lua Challenge: the Catastrophes plugin - NiLSPACE - 05-22-2015 I suppose it's kinda working: TOO MUCH! RE: Lua Challenge: the Catastrophes plugin - xoft - 05-22-2015 There's currently no cWorld:ForEachChunk() API function which would help you, but it shouldn't be too difficult to add it. RE: Lua Challenge: the Catastrophes plugin - NiLSPACE - 05-22-2015 Apache License 2.0 is allowed right? RE: Lua Challenge: the Catastrophes plugin - NiLSPACE - 05-23-2015 That moment when you realize you are really cruel for the villagers: It really killed the performance though: I'll have to randomize it, but it looks less good if I do that Btw, I had had a question about the license above here RE: Lua Challenge: the Catastrophes plugin - jan64 - 05-23-2015 So, we need luajit! |