From 327b12d488a7f001e21826a5b9e1df03af44c7ae Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 30 Mar 2017 21:59:30 +0200 Subject: Assert some variable types obtained from lua automation --- advtrains/advtrains_luaautomation/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'advtrains/advtrains_luaautomation/init.lua') diff --git a/advtrains/advtrains_luaautomation/init.lua b/advtrains/advtrains_luaautomation/init.lua index 87f5921..71808e7 100644 --- a/advtrains/advtrains_luaautomation/init.lua +++ b/advtrains/advtrains_luaautomation/init.lua @@ -16,6 +16,13 @@ atlatc = { envs = {}} minetest.register_privilege("atlatc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false }) +--assertt helper. error if a variable is not of a type +function assertt(var, typ) + if type(var)~=typ then + error("Assertion failed, variable has to be of type "..typ) + end +end + local mp=minetest.get_modpath("advtrains_luaautomation") if not mp then error("Mod name error: Mod folder is not named 'advtrains_luaautomation'!") -- cgit v1.2.3