Page 1 of 1

Custom Biomes

Posted: 15 Jul 2018, 18:03
by KINGTUT10101
Screenshot_20180715-103533.png
An example of what you could create while using this technique. As you can see, there are multiple ground types in this map, which isn't normally possible through map generation

In this tutorial, I'll be showing you how to make custom biomes. Using this technique, you'll have full control over the biome's size, position, and decorations. This will also allow you to have more than one ground type in map generation. This process uses a combination of decoration spawning and basic fun. Using the decoration spawning, we can put decorations in world generation that place a new ground type underneath them in order to create new biomes. You will also be able to provide some decorations to have spawned in your biome as well.

Some Sample Code

Code: Select all

[
	{
		"author":"Kingtut101",
		"autobuild":false,
		"borderframes":[
			{
				"count":16,
				"h":16,
				"w":32,
				"x":0,
				"y":32
			}
		],
		"edgeborderframes":[
			{
				"count":32,
				"h":32,
				"w":16,
				"x":0,
				"y":144
			}
		],
		"edgeframes":[
			{
				"count":12,
				"h":48,
				"w":16,
				"x":0,
				"y":96
			}
		],
		"frames":[
			{
				"bmp":"stoneground.png"
			}
		],
		"height":1,
		"id":"stoneground.kt101",
		"text":"Hard,graygroundforyourcities.",
		"title":"Stone",
		"type":"ground",
		"water":false,
		"width":1
	},
	{
		"author":"Kingtut101",
		"category":"$cat_terrain00",
		"drawground":true,
		"framealignmentarea":true,
		"frames":[
			{
				"bmp":"blank.png"
			},
			{
				"steal":"$searocks00"
			}
		],
		"fun":[
			{
				"actions":[
					{
						"id":"stoneground.kt101",
						"type":"build"
					},
					{
						"type":"remove"
					}
				],
				"condition":{
					"inner":[
						{
							"invert":true,
							"type":"wire"
						},
						{
							"frame":0,
							"type":"building"
						}
					],
					"type":"and"
				},
				"p":1
			},
			{
				"actions":[
					{
						"id":"stoneground.kt101",
						"type":"build"
					}
				],
				"condition":{
					"inner":[
						{
							"invert":true,
							"type":"wire"
						},
						{
							"frame":1,
							"type":"building"
						}
					],
					"type":"and"
				},
				"p":1
			}
		],
		"height":1,
		"hidden":false,
		"id":"rocks.kt101",
		"price":100,
		"pricefactor":0,
		"spawn":{
			"height":300,
			"p":1,
			"radius":150
		},
		"title":"Rocks",
		"type":"decoration",
		"width":1
	}
]
Before you start creating your own custom biomes there are a few things that are needed:
-Blank frames
-Decoration frames (optional)
-A ground type
-A decoration that will be spawned in map generation

All of the custom biome's functionality rests in the decoration code, so don't worry too much about the ground code. Next I'll begin to talk about how this all works in more detail.

Code: Select all

"fun":[
			{
				"actions":[
					{
						"id":"stoneground.kt101",
						"type":"build"
					},
					{
						"type":"remove"
					}
				],
				"condition":{
					"inner":[
						{
							"invert":true,
							"type":"wire"
						},
						{
							"frame":0,
							"type":"building"
						}
					],
					"type":"and"
				},
				"p":1
			},
			{
				"actions":[
					{
						"id":"stoneground.kt101",
						"type":"build"
					}
				],
				"condition":{
					"inner":[
						{
							"invert":true,
							"type":"wire"
						},
						{
							"frame":1,
							"type":"building"
						}
					],
					"type":"and"
				},
				"p":1
			}
		],
Here is the fun code. This is the part that creates the biome. What this is doing is detecting what frame the decoration is using and acting accordingly. In the first json I provided some frames called "blank.png". Because this frame was provided first, this becomes frame 0. What this fun code will do if it detects that the decoration is on frame 0 is make it place the Stone ground and then delete itself. However, as you might have noticed, I provided another frame. This is what will be used to decorate my biome. This frame will be frame 1. The fun code will detect if it is on frame one and if it is it will make it place the Stone ground, but instead of deleting it it will keep it. This is how we can get some decorations in our biomes.

The next part requires you to add decoration spawning code. You can find the tutorial here:
https://theotown.com/forum/viewtopic.php?f=41&t=1355

Of course, this is just an example of how to accomplish custom biomes and I'm sure that there are better ways to code such a thing. There are probably an endless amount of combinations for custom biomes. However, this tutorial should get across the basic points. I will be providing the example plug-in below and if you don't understand this concept I would recommend that you take a look at it and tweak it to your liking. Feel free to reuse this plug-in code in your own plug-ins. Just make sure to credit me.

Re: Custom Biomes

Posted: 15 Jul 2018, 18:07
by KINGTUT10101
Here is another example of what you can accomplish with this concept. For those of you who would like to use this plug-in, it will be released as part of a future plug-in pack.

Re: Custom Biomes

Posted: 15 Jul 2018, 18:53
by KINGTUT10101
That could work, but would you be able to build stuff on it?

Re: Custom Biomes

Posted: 15 Jul 2018, 20:46
by KINGTUT10101
I don't think they can spawn in world gen though.

Re: Custom Biomes

Posted: 15 Jul 2018, 21:18
by yusuf8a684
Kingtut, it is awesome! I hope you can make mountains plugins with that idea. It doesn't need to look like 3D, just rock decals and trees cant grow on it. If there is a plugin about that can i have a link, please?

Re: Custom Biomes

Posted: 16 Jul 2018, 03:31
by KINGTUT10101
yusuf8a684 wrote:
15 Jul 2018, 21:18
Kingtut, it is awesome! I hope you can make mountains plugins with that idea. It doesn't need to look like 3D, just rock decals and trees cant grow on it. If there is a plugin about that can i have a link, please?
There isn't anything like that yet, but I'm sure someone might make it someday

Re: Custom Biomes

Posted: 16 Jul 2018, 11:26
by yusuf8a684
KINGTUT10101 wrote:
16 Jul 2018, 03:31
yusuf8a684 wrote:
15 Jul 2018, 21:18
Kingtut, it is awesome! I hope you can make mountains plugins with that idea. It doesn't need to look like 3D, just rock decals and trees cant grow on it. If there is a plugin about that can i have a link, please?
There isn't anything like that yet, but I'm sure someone might make it someday
Where can i find this Kingtut?

Re: Custom Biomes

Posted: 16 Jul 2018, 16:52
by KINGTUT10101
It's at the bottom of the tutorial

Re: Custom Biomes

Posted: 10 Aug 2021, 16:45
by Yakka
KINGTUT10101 wrote:
15 Jul 2018, 18:07
Here is another example of what you can accomplish with this concept. For those of you who would like to use this plug-in, it will be released as part of a future plug-in pack.
Your nature pack beach

Re: Custom Biomes

Posted: 13 Sep 2021, 10:15
by Yakka
If you have lag problem try use
On built fun instead fun

Re: Custom Biomes

Posted: 15 Sep 2021, 00:32
by KINGTUT10101
Ideally, you should use lua if possible. I've heard its faster than fun. Even if that's not true, it's much more flexible and powerful.

Re: Custom Biomes

Posted: 15 Sep 2021, 06:38
by Yakka
KINGTUT10101 wrote:
15 Sep 2021, 00:32
Ideally, you should use lua if possible. I've heard its faster than fun. Even if that's not true, it's much more flexible and powerful.
I know but im still trying to figure it out how to
Just know how to make gui and mixer tool based on tree planter tool