Create
Name
Type
Description
Type
Description
-- init.lua
function init()
local cat_x = chunk.X * chunk.Size
local cat_y = chunk.Y * chunk.Size
local name_starts = {"Snow", "Fluff", "Fuzz"}
local name_ends = {"ball", "ikins", "y"}
local cat_name_start = name_starts[math.abs(chunk.X)%3 +1]
local cat_name_end = name_ends[math.abs(chunk.Y)%3 +1]
local cat_data = {
name = cat_name_start..cat_name_end,
health = math.random(10)
}
local cat = api.entity.Create("cat", cat_x, cat_y, 0, cat_data)
if cat.Data.health > 8 then
print("My name is "..cat.Data.name.." and I am a strong cat!")
end
end
-- Whenever a chunk is loaded, create a cat in the bottom left corner of the chunk.
-- The cat has two custom fields: 'name' and 'health'.
-- Its 'name' is generated based on this chunk's XY coordinates.
-- Its 'health' is a random value between 1 and 10.
-- Prints (subject to randomness):
-- My name is Snowball and I am a strong cat!
-- My name is Fluffy and I am a strong cat!
-- My name is Fuzzball and I am a strong cat!
-- My name is Fuzzy and I am a strong cat!
-- My name is Fluffikins and I am a strong cat!Last updated