main.lua

socketmud/scripts/main.lua · 909 B

From the archive socketmud-lua.v2.tar.gz

Download the archive   « Back to the archive contents

plr_list = {}

--Do not edit this file while the mud is running.


function player_input(plr, command, args)
	local k,v, found, brain
	found = false
	brain = plr_list[plr].brain;
	
	for k,v in pairs(cmd_list) do
		if string.sub(k,1,string.len(command)) == command then
			--log_string(k .. "sec: " .. brain.security .. "sec: ".. v.security)
			if brain.security >= v.security then
				v:func(brain, args)
				found = true;
				break
			end
		end
	end
	if found == false then
		text_to_player(plr, "Huh?\n\r");
	end
end

function register_player(plr, name)
	local player_data = {}
	player_data.name = name
	player_data.brain = player_brain:create()
	player_data.brain:load(name, plr);
	--Will add link to player structure when one is completed.
	plr_list[plr] = player_data;
end

function unregister_player(plr)
	if plr_list[plr] ~= nil then
		plr_list[plr] = nil
	end
end

Site Stats

Snippets: 1791
Codebases: 571