inside_mapgen_env.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. core.log("info", "Hello World")
  2. local function do_tests()
  3. assert(core == minetest)
  4. -- stuff that should not be here
  5. assert(not core.get_player_by_name)
  6. assert(not core.object_refs)
  7. -- stuff that should be here
  8. assert(core.register_on_generated)
  9. assert(core.get_node)
  10. assert(core.spawn_tree)
  11. assert(ItemStack)
  12. local meta = ItemStack():get_meta()
  13. assert(type(meta) == "userdata")
  14. assert(type(meta.set_tool_capabilities) == "function")
  15. assert(core.registered_items[""])
  16. assert(core.save_gen_notify)
  17. -- alias handling
  18. assert(core.registered_items["unittests:steel_ingot_alias"].name ==
  19. "unittests:steel_ingot")
  20. -- fallback to item defaults
  21. assert(core.registered_items["unittests:description_test"].on_place == true)
  22. end
  23. -- first thread to get here runs the tests
  24. if core.ipc_cas("unittests:mg_once", nil, true) then
  25. -- this is checked from the main env
  26. core.ipc_set("unittests:mg", { pcall(do_tests) })
  27. end
  28. core.register_on_generated(function(vm, pos1, pos2, blockseed)
  29. local n = tonumber(core.get_mapgen_setting("chunksize")) * 16 - 1
  30. assert(pos2:subtract(pos1) == vector.new(n, n, n))
  31. end)