minetest mod.
Go to file
Coder12a fe4db5b70c Update README.md 2018-11-09 16:04:48 -06:00
LICENSE Initial commit 2018-10-22 13:47:34 -05:00
README.md Update README.md 2018-11-09 16:04:48 -06:00
api.txt Update. 2018-11-09 15:54:41 -06:00
async.lua Update. 2018-11-09 15:54:41 -06:00
depends.txt Add files 2018-10-29 16:32:52 -05:00
description.txt Add files 2018-10-29 16:32:52 -05:00
init.lua add minetest.async 2018-11-08 23:52:28 -06:00
mod.conf Add files 2018-10-29 16:32:52 -05:00
node_funcs.lua Update. 2018-11-09 15:54:41 -06:00

README.md

extended_api

extended_api is a minetest mod that extends the current minetest api. It adds two new node events and contains async functions.

Usage Async

  1. create a async pool.
pool = minetest.Async.create_async_pool()
  1. set the priority of the async pool to high.
minetest.Async.priority(pool,50,500)
  1. iterate from 1 to 50 and log the value i.
minetest.Async.iterate(pool,1,50,function(i)
	minetest.log(i)
end)
  1. run throught each element in a table.
local array = {"start","text2","text3","text4","text5","end"}
minetest.Async.foreach(pool,array, function(k,v)
	minetest.log(v)
end)
  1. async do while loop.
local c = 50
minetest.Async.do_while(pool,function() return c>0 end, function()
	minetest.log(c)
	c = c - 1
end)
  1. register a async globalstep. this one spams the chat with the word spam.
minetest.Async.register_globalstep(pool,function(dtime) 
	minetest.chat_send_all("spam")
end)
  1. chain task runs a group of functions from a table.
minetest.Async.chain_task(pool,{
	function(args)
	args.count = 1
	minetest.log(args.count)
	return args
	end,
	function(args)
	args.count = args.count + 1
	minetest.log(args.count)
	return args
end})
  1. adds a single function to the task queue. This is a sort of waiting list.
minetest.Async.queue_task(pool,function() 
	minetest.log("Hello World!")
end)

Usage Node

  1. this covers both functions. I made this for a way to awake node timers without abms.
minetest.register_node("default:stone", {
	description = "Stone",
	tiles = {"default_stone.png"},
	groups = {cracky = 3, stone = 1},
	drop = 'default:cobble',
	legacy_mineral = true,
	sounds = default.node_sound_stone_defaults(),
	on_construct_node_near_by = function(pos,other_pos,name)
		if name == "tnt:tnt" then
			minetest.chat_send_all("Do not place tnt near me thank you!")
		end
	end,
	on_destruct_node_near_by = function(pos,other_pos,name)
		if name == "default:dirt" then
			minetest.chat_send_all("I hate dirt too!")
		end
	end,
})