summaryrefslogtreecommitdiff
path: root/src/irrlicht_changes/irrUString.h
diff options
context:
space:
mode:
authorMiniontoby <tobias.gaarenstroom@gmail.com>2020-05-27 17:53:46 +0000
committersfan5 <sfan5@live.de>2020-06-13 23:13:44 +0200
commitb0500f9db9e7784640b22e66c7731201852d061e (patch)
tree671c7a90b443e07240325fa377f6863e2b52c70d /src/irrlicht_changes/irrUString.h
parentf664ff128575991f7e47c58dec25e73f1d3699af (diff)
downloadminetest-b0500f9db9e7784640b22e66c7731201852d061e.tar.gz
minetest-b0500f9db9e7784640b22e66c7731201852d061e.tar.bz2
minetest-b0500f9db9e7784640b22e66c7731201852d061e.zip
Translated using Weblate (Dutch)
Currently translated at 83.1% (1071 of 1288 strings)
Diffstat (limited to 'src/irrlicht_changes/irrUString.h')
0 files changed, 0 insertions, 0 deletions
a> 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
--clipboard = {trainlen = number, [n] = {type = string, flipped = bool, }

-- Yaw is in radians. There are 2pi rad in a circle. North is the 0 point and the angle increases anticlockwise.
-- 4.712389 = 1.5pi; sin(1.5pi) = -1
-- 7.853981 = 2.5pi; sin(2.5pi) = 1

minetest.register_tool("advtrains:copytool", {
	description = attrans("Train copy/paste tool\n\nLeft-click: copy train\nRight-click: paste train"),
	inventory_image = "advtrains_copytool.png",
	wield_image = "advtrains_copytool.png",
	stack_max = 1,
	-- Paste: Take the clipboard and the player yaw, and attempt to place a new train in the world.
	-- The front of the train is used as the start of the new train and it proceeds backwards from
	-- the direction of travel.
	on_place = function(itemstack, placer, pointed_thing)
			if ((not pointed_thing.type == "node") or (not placer.get_player_name)) then
				return
			end
			local pname = placer:get_player_name()

			local node=minetest.get_node_or_nil(pointed_thing.under)
			if not node then atprint("[advtrains]Ignore at placer position") return itemstack end
			local nodename=node.name
			if(not advtrains.is_track_and_drives_on(nodename, {default=true})) then
				atprint("no track here, not placing.")
				return itemstack
			end
			if not minetest.check_player_privs(placer, {train_operator = true }) then
				minetest.chat_send_player(pname, "You don't have the train_operator privilege.")
				return itemstack
			end
			if not minetest.check_player_privs(placer, {train_admin = true }) and minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
				return itemstack
			end
			local tconns=advtrains.get_track_connections(node.name, node.param2)
			local yaw = placer:get_look_horizontal()
			local plconnid = advtrains.yawToClosestConn(yaw, tconns)

			local prevpos = advtrains.get_adjacent_rail(pointed_thing.under, tconns, plconnid, {default=true})
			if not prevpos then
				minetest.chat_send_player(pname, "The track you are trying to place the wagon on is not long enough!")
				return
			end

			local meta = itemstack:get_meta()
			if not meta then
				minetest.chat_send_player(pname, attrans("The clipboard couldn't access the metadata. Paste failed."))
			return
			end
			local clipboard = meta:get_string("clipboard")
			if (clipboard == "") then
				minetest.chat_send_player(pname, "The clipboard is empty.");
				return
			end
			clipboard = minetest.deserialize(clipboard)
			if (clipboard.wagons == nil) then
				minetest.chat_send_player(pname, "The clipboard is empty.");
				return
			end

			local wagons = {}
			local n = 1
			for _, wagonProto in pairs(clipboard.wagons) do
				local wagon = advtrains.create_wagon(wagonProto.type, pname)