From 646f77ec6bc27af231b6ff8974e631b86188beb6 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 19 May 2019 23:03:48 +0500 Subject: Implemented block-api --- cwd/assets/altcraft/scripts/blocks.lua | 22 ++++++++++++++++++++-- cwd/assets/altcraft/scripts/init.lua | 9 +++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'cwd') diff --git a/cwd/assets/altcraft/scripts/blocks.lua b/cwd/assets/altcraft/scripts/blocks.lua index ad00742..07a1f77 100644 --- a/cwd/assets/altcraft/scripts/blocks.lua +++ b/cwd/assets/altcraft/scripts/blocks.lua @@ -1,2 +1,20 @@ -print("Hello from altcraft/blocks!") -return "CONTENT OF ac/blocks" \ No newline at end of file +local function GetBlockInfo(blockPos) + print("Request data for "..blockPos) + local bi = BlockInfo.new() + bi.collides = true + bi.blockstate = "" + bi.variant = "" + return bi +end + +local function RegisterBlocks() + AC.RegisterBlock(BlockId.new(1,0), true, "stone", "normal") + AC.RegisterBlock(BlockId.new(2,0), true, "grass", "snowy=false") + AC.RegisterBlock(BlockId.new(3,0), true, "dirt", "normal") + AC.RegisterBlock(BlockId.new(31,1), false, "tall_grass", "normal") +end + +return { + GetBlockInfo = GetBlockInfo, + RegisterBlocks = RegisterBlocks, +} \ No newline at end of file diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua index f001017..5021a00 100644 --- a/cwd/assets/altcraft/scripts/init.lua +++ b/cwd/assets/altcraft/scripts/init.lua @@ -5,6 +5,7 @@ local plugin = { onUnload = nil, onChangeState = nil, onTick = nil, + onRequestBlockInfo = nil, } function plugin.onLoad () @@ -32,8 +33,12 @@ function plugin.onTick (deltaTime) end end -blocks = require("altcraft/blocks") -print("From init: "..blocks) +local blocks = require("altcraft/blocks") +blocks.RegisterBlocks() + +function plugin.onRequestBlockInfo(blockPos) + return blocks.GetBlockInfo(blockPos) +end AC.RegisterPlugin(plugin) plugin = nil \ No newline at end of file -- cgit v1.2.3