aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorAndrei Stepanov <adem4ik@gmail.com>2020-05-03 11:07:25 +0000
committersfan5 <sfan5@live.de>2020-06-13 23:13:43 +0200
commit6f3fc76db3bd336d6cafa5be023e76b35fe823e0 (patch)
tree54b90a01fc701a53d8a8abcea119cf10be38fdc6 /build
parent3d17394410f33a19c1dd9314f6d66d6fbc30bae7 (diff)
Translated using Weblate (Russian)
Currently translated at 96.0% (1237 of 1288 strings)
Diffstat (limited to 'build')
0 files changed, 0 insertions, 0 deletions
09'>109 110 111 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")

default.shop = {}
default.shop.current_shop = {}
default.shop.formspec = {
	customer = function(pos)
		local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
		local formspec = "size[8,9.5]"..
		"label[0,0;" .. S("Customer gives (pay here!)") .. "]"..
		"list[current_player;customer_gives;0,0.5;3,2;]"..
		"label[0,2.5;" .. S("Customer gets:") .. "]"..
		"list[current_player;customer_gets;0,3;3,2;]"..
		"label[5,0;" .. S("Owner wants:") .. "]"..
		"list["..list_name..";owner_wants;5,0.5;3,2;]"..
		"label[5,2.5;" .. S("Owner gives:") .. "]"..
		"list["..list_name..";owner_gives;5,3;3,2;]"..
		"list[current_player;main;0,5.5;8,4;]"..
		"button[3,2;2,1;exchange;" .. S("Exchange") .. "]"
		return formspec
	end,
	owner = function(pos)
		local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
		local formspec = "size[8,9.5]"..
		"label[0,0;" .. S("Customers gave:") .. "]"..
		"list["..list_name..";customers_gave;0,0.5;3,2;]"..
		"label[0,2.5;" .. S("Your stock:") .. "]"..
		"list["..list_name..";stock;0,3;3,2;]"..
		"label[5,0;" .. S("You want:") .. "]"..
		"list["..list_name..";owner_wants;5,0.5;3,2;]"..
		"label[5,2.5;" .. S("In exchange, you give:") .. "]"..
		"list["..list_name..";owner_gives;5,3;3,2;]"..
		"label[0,5;" .. S("Owner, Use (E)+Place (right mouse button) for customer interface") .. "]"..
		"list[current_player;main;0,5.5;8,4;]"
		return formspec
	end,
}

local have_pipeworks = minetest.global_exists("pipeworks")

default.shop.check_privilege = function(listname,playername,meta)
	--[[if listname == "pl1" then
		if playername ~= meta:get_string("pl1") then
			return false
		elseif meta:get_int("pl1step") ~= 1 then
			return false
		end
	end
	if listname == "pl2" then
		if playername ~= meta:get_string("pl2") then
			return false
		elseif meta:get_int("pl2step") ~= 1 then
			return false
		end
	end]]
	return true
end


default.shop.give_inventory = function(inv,list,playername)
	player = minetest.get_player_by_name(playername)
	if player then
		for k,v in ipairs(inv:get_list(list)) do
			player:get_inventory():add_item("main",v)
			inv:remove_item(list,v)
		end
	end
end

default.shop.cancel = function(meta)
	--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
	default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
	meta:set_string("pl1","")
	meta:set_string("pl2","")
	meta:set_int("pl1step",0)
	meta:set_int("pl2step",0)]]
end

default.shop.exchange = function(meta)
	--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
	default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
	meta:set_string("pl1","")
	meta:set_string("pl2","")
	meta:set_int("pl1step",0)
	meta:set_int("pl2step",0)]]
end

minetest.register_node("currency:shop", {
	description = S("Shop"),
	paramtype2 = "facedir",
	tiles = {"shop_top.png",
			"shop_top.png",
			"shop_side.png",
			"shop_side.png",
			"shop_side.png",
			"shop_front.png"},
	inventory_image = "shop_front.png",
	groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
	sounds = default.node_sound_wood_defaults(),
	after_place_node = function(pos, placer, itemstack)
		local owner = placer:get_player_name()
		local meta = minetest.get_meta(pos)
		meta:set_string("infotext", S("Exchange shop (owned by @1)", owner))
		meta:set_string("owner",owner)
		--[[meta:set_string("pl1","")
		meta:set_string("pl2","")]]
		local inv = meta:get_inventory()
		inv:set_size("customers_gave", 3*2)