Shhhh don't tell anyone 
Here is another plugin I created. It allows you to execute a Lua script in the webadmin.

Here is another plugin I created. It allows you to execute a Lua script in the webadmin.
![[Image: 5CTew.png]](http://puu.sh/5CTew.png)
Random Chitchat 2012-2016
|
Shhhh don't tell anyone
![]() Here is another plugin I created. It allows you to execute a Lua script in the webadmin. ![]()
12-06-2013, 12:51 AM
12-06-2013, 01:08 AM
Yea I'm using math.random() so if you use /regen you get other terrain.
I love seeing what I can do with plugins.
12-06-2013, 01:50 AM
I think you can make it regen-safe by calling math.randomseed() with a number as the argument that is calculated from the chunk X and Z coords - for example:
math.randomseed((a_ChunkX % 1234567) + (a_ChunkZ % 7654321) * 321); math.random();This should provide the same random values for the same chunk repeatedly. The extra random() call is there because the first random number returned is "not random enough" - see http://lua-users.org/wiki/MathLibraryTutorial 's math.random section.
But that would mean I get the same height for every X, Z coordinate in the chunk? Would this work if I want to get a different height for every block?:
local CoordX = tonumber(ChunkX .. "." .. X) local CoordZ = tonumber(ChunkZ .. "." .. Z) math.randomseed(((CoordX % 1234567) + (CoordZ % 7654321) * 321)); Hurray I have something that actualy works ![]() ChunkDesc:SetUseDefaultHeight(false) for X=0, 15 do for Z=0, 15 do if ChunkDesc:GetBiome(X, Z) == biSwampland then ChunkDesc:SetUseDefaultFinish(false) local Calculation = math.sqrt(((ChunkX % 1234567) + (ChunkZ % 7654321) * ((X + 1) * (Z + 1)))) / (ChunkX + (X + 1)) / (ChunkZ + (Z + 1)) math.randomseed(Calculation); math.random() local Height = math.random(60, 61) ChunkDesc:SetHeight(X, Z, Height) for Y=2, Height -3 do ChunkDesc:SetBlockTypeMeta(X, Y, Z, E_BLOCK_STONE, 0) end for Y=Height-3, Height-1 do ChunkDesc:SetBlockTypeMeta(X, Y, Z, E_BLOCK_DIRT, 0) end ChunkDesc:SetBlockTypeMeta(X, Height, Z, E_BLOCK_GRASS, 0) ChunkDesc:SetBlockTypeMeta(X, 1, Z, E_BLOCK_BEDROCK, 0) for Y=61, Height, -1 do local Block = ChunkDesc:GetBlockType(X, Y, Z) print(Y, Height) if Block == E_BLOCK_AIR then ChunkDesc:SetBlockTypeMeta(X, Y, Z, E_BLOCK_WATER, 0) elseif Block == E_BLOCK_GRASS and Y < Height then ChunkDesc:SetBlockTypeMeta(X, Y, Z, E_BLOCK_DIRT, 0) elseif Block ~= E_BLOCK_WATER then --break; end end Height = ChunkDesc:GetHeight(X, Z) local HighestBlock = ChunkDesc:GetBlockType(X, Height, Z) if HighestBlock == E_BLOCK_LILY_PAD then if ChunkDesc:GetBlockType(X, Height -1, Z) ~= E_BLOCK_WATER then end ChunkDesc:SetBlock(X, Height, Y, E_BLOCK_AIR, 0) end end end end ![]()
12-06-2013, 04:24 AM
You shouldn't call math.randomseed() for each column, but only once per chunk.
12-06-2013, 06:23 AM
Realy? But how do I get a new height for each block then?
12-06-2013, 06:33 AM
math.randomseed((ChunkX % 1234567) + (ChunkZ % 7654321) * 23); math.random(); for X = 0, 15 do for Z = 0, 15 do if ChunkDesc:GetBiome(X, Z) == biSwampland then ChunkDesc:SetUseDefaultFinish(false); local Height = math.random(60, 61); ... Thanks given by: NiLSPACE
12-07-2013, 12:00 AM
Because I can't find the problem about the pickups spawning, and a recompile doesn't work I have exported a .dmp file using "TaskInfo" and uploaded it: http://www.mediafire.com/download/bo6kto...287%29.zip
12-07-2013, 06:57 AM
You know what would be cool? A MCS t-shirt to show off
![]() ![]() ![]() |
« Next Oldest | Next Newest »
|