summaryrefslogtreecommitdiff
path: root/streetsmod/init.lua
blob: e7de999ab71b3f113e6a1db0176cbc972740b73d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--[[
	StreetsMod 1.1 by webdesigner97:
		License : CC-BY-NC (see license.txt)
		Readme	: see readme.txt
		Forum	: http://bit.ly/12cPMeo
		Depends	: default
]]
-- Create variables and tables
	print("Streets: Creating variables and tables...")
	streets	= {}
	streets.version	= "1.3 indev"
	streets.modpath = minetest.get_modpath("streets")
	streets.extendedBy	= {}
	streets.load = {
		start = os.clock(),
		fin = 0
	}
	
-- Check for mods which change this mod's beahaviour
	print("Streets: Checking installed mods...")
	if minetest.get_modpath("wool")	 then
		print("'Wool' is installed \n\t => You can craft labels for your asphalt blocks")
		streets.extendedBy.wool = true
	else
		print("'Wool' not installed \n\t => You can't craft any labels")
		streets.extendedBy.wool = false
	end
	if minetest.get_modpath("technic")	then
		print("'Technic' is installed \n\t => You can use its concrete also in this mod")
		streets.extendedBy.technic = true
	else
		print("'Technic' not installed \n\t => StreetsMod will register its own concrete block")
		streets.extendedBy.technic = false
	end
	if minetest.get_modpath("moreblocks") then
		print("'Moreblocks' is installed \n\t => There will be stairs and slabs'")
		streets.extendedBy.moreblocks = true
	else
		print("'Moreblocks' not installed \n\t => There won't be stairs and slabs'")
		streets.extendedBy.moreblocks = false
	end
	if minetest.get_modpath("mesecons") then
		print("'Mesecons' is installed \n\t => Trafficlights might be available. Checking for digilines. Streetlamps available")
		streets.extendedBy.mesecons = true
	else
		print("'Mesecons' not installed \n\t => No trafficlight and streetlamps, sorry.")
		streets.extendedBy.mesecons = false
	end
	if minetest.get_modpath("digilines") then
		print("'Digilines' is installed \n\t => Trafficlights might be available")
		streets.extendedBy.digilines = true
	else
		print("'Digilines' not installed \n\t => No trafficlight, sorry.")
		streets.extendedBy.digilines = false
	end
	if minetest.get_modpath("prefab") then
		print("'Prefab concrete' is installed \n\t => Use its concrete block for streets' crafting recipes.")
		streets.extendedBy.prefab = true
	else
		print("'Prefab concrete' not installed \n\t => Streets will register its own concrete block.")
		streets.extendedBy.prefab = false
	end
	
-- Streets chatcommand
	local function round(num, idp)
		local mult = 10^(idp or 0)
		return math.floor(num * mult + 0.5) / mult
	end
	minetest.register_chatcommand("streets",{
		description = "Check version of you installed StreetsMod and find information",
		func = function(name,param)
			minetest.show_formspec(name, "streets:streetsform", table.concat({
				"size[10,6]",
				"label[0,1;Wool installed: " .. tostring(streets.extendedBy.wool) .. "]",
				"label[0,1.5;Technic installed: " .. tostring(streets.extendedBy.technic) .. "]",
				"label[0,2;Moreblocks installed: " .. tostring(streets.extendedBy.moreblocks) .. "]",
				"label[0,2.5;Mesecons installed: " .. tostring(streets.extendedBy.mesecons) .. "]",
				"label[0,3;Digilines installed: " .. tostring(streets.extendedBy.digilines) .. "]",
				"label[0,3.5;Prefab installed: " .. tostring(streets.extendedBy.prefab) .. "]",
				"label[0,4.5;Running version: " .. streets.version .. "]",
				"label[0,5;Load time: " .. round(streets.load.fin - streets.load.start,4) .. "s]"
			}))
		end
	})
	
-- Done	
	print("Streets: Setup completed, have fun with StreetsMod ".. streets.version .."!")
	print("Streets: Special thanks to everyone who contributed to this mod (except myself): Immanuel_Kant and philipbenr!")
	streets.load.fin = os.clock()