aboutsummaryrefslogtreecommitdiff
path: root/advtrains_train_steam
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-01-07 23:58:05 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-01-07 23:58:05 +0100
commite9c76100a1f5ff474a4ed65555c3249b791bbf10 (patch)
treeb70910b94917a4d85f52aa1aaa9ddd0fe56b7a06 /advtrains_train_steam
parent8655eebc5fe8bf484ea2d96041b7b1bf70242e1b (diff)
downloadadvtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.tar.gz
advtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.tar.bz2
advtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.zip
Add ATC "K" command
This command kicks out all passengers when the train is stopped and its doors are open. In addtion, a wagon:is_driver_stand(seat) function was added to allow finding out easily if a seat is the driver stand of the wagon.
Diffstat (limited to 'advtrains_train_steam')
0 files changed, 0 insertions, 0 deletions
> 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
--Minetest
--Copyright (C) 2014 sapier
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

--------------------------------------------------------------------------------
local function get_formspec(tabview, name, tabdata)
	
	local index = menudata.worldlist:get_current_index(
				tonumber(core.setting_get("mainmenu_last_selected_world"))
				)

	local retval =
		"button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
		"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
		"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
		"button[8.5,4.9;3.25,0.5;start_server;".. fgettext("Start Game") .. "]" ..
		"label[4,-0.25;".. fgettext("Select World:") .. "]"..
		"vertlabel[0,-0.25;".. fgettext("START SERVER") .. "]" ..
		"checkbox[0.5,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
		dump(core.setting_getbool("creative_mode")) .. "]"..
		"checkbox[0.5,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
		dump(core.setting_getbool("enable_damage")) .. "]"..
		"checkbox[0.5,1.15;cb_server_announce;".. fgettext("Public") .. ";" ..
		dump(core.setting_getbool("server_announce")) .. "]"..
		"field[0.8,3.2;3.5,0.5;te_playername;".. fgettext("Name") .. ";" ..
		core.setting_get("name") .. "]" ..
		"pwdfield[0.8,4.2;3.5,0.5;te_passwd;".. fgettext("Password") .. "]"
		
	local bind_addr = core.setting_get("bind_address")
	if bind_addr ~= nil and bind_addr ~= "" then
		retval = retval ..
			"field[0.8,5.2;2.25,0.5;te_serveraddr;".. fgettext("Bind Address") .. ";" ..
			core.setting_get("bind_address") .."]" ..
			"field[3.05,5.2;1.25,0.5;te_serverport;".. fgettext("Port") .. ";" ..
			core.setting_get("port") .."]"
	else
		retval = retval ..
			"field[0.8,5.2;3.5,0.5;te_serverport;".. fgettext("Server Port") .. ";" ..
			core.setting_get("port") .."]"
	end
	
	retval = retval ..
		"textlist[4,0.25;7.5,3.7;srv_worlds;" ..
		menu_render_worldlist() ..
		";" .. index .. "]"
	
	return retval
end

--------------------------------------------------------------------------------
local function main_button_handler(this, fields, name, tabdata)

	local world_doubleclick = false

	if fields["srv_worlds"] ~= nil then
		local event = core.explode_textlist_event(fields["srv_worlds"])

		if event.type == "DCL" then
			world_doubleclick = true
		end
		if event.type == "CHG" then
			core.setting_set("mainmenu_last_selected_world",
				menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds")))
			return true
		end
	end

	if menu_handle_key_up_down(fields,"srv_worlds","mainmenu_last_selected_world") then
		return true
	end

	if fields["cb_creative_mode"] then
		core.setting_set("creative_mode", fields["cb_creative_mode"])
		return true
	end

	if fields["cb_enable_damage"] then
		core.setting_set("enable_damage", fields["cb_enable_damage"])
		return true
	end

	if fields["cb_server_announce"] then
		core.setting_set("server_announce", fields["cb_server_announce"])
		return true
	end

	if fields["start_server"] ~= nil or
		world_doubleclick or
		fields["key_enter"] then
		local selected = core.get_textlist_index("srv_worlds")
		if selected ~= nil then
			gamedata.playername     = fields["te_playername"]
			gamedata.password       = fields["te_passwd"]
			gamedata.port           = fields["te_serverport"]
			gamedata.address        = ""