Running code after logging in

Post Reply
chrio
Posts: 73
Joined: Mon Aug 22, 2016 11:34 am

Running code after logging in

Post by chrio »

Is there a built in way of running code after we have logged in with the stored name and password?

My current solution is using a handler for the sysConnectionEvent to set up a temporary trigger that detects my prompt. The trigger runs my afterLogon() function and then deletes itself. It works fine, but is there a better way to do all this?

Code: Select all

--------------------------------------
--  Handler for sysConnectionEvent  --
--------------------------------------
function sysConnectionEventHandler()
	cecho("<red>sysConnectionEventHandler() running at this point.\n")

	-- create a color trigger for prompt colors
	tempTriggerID = tempColorTrigger(8, 0, [[
		killTrigger(tempTriggerID)
		tempTriggerID=nil
		afterLogon()
		]])

end

function afterLogon()
	cecho("<red>afterLogon() running at this point.\n")
end

User avatar
SlySven
Posts: 1022
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Running code after logging in

Post by SlySven »

When you say "my prompt" do you mean the MUD server asking for your username then the password for that characater OR the Hit Points/Movement Points/Magic Points sort of thing?

chrio
Posts: 73
Joined: Mon Aug 22, 2016 11:34 am

Re: Running code after logging in

Post by chrio »

The second one, the HP/SP/etc command prompt that I get once I am logged in with my credentials and can start controlling my character. Basically I use this to do all my mundane tasks after I log on with my character.

I got it working ok with the solution I mention, so that's ok, but i'm curious how other people have solved this.

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Running code after logging in

Post by Nyyrazzilyss »

Similiar, but my main/script initializing occurs prior to login: I start when mudlet itself loads, prior to logging in to the mud. Which event you choose to use to move control into your script is really personal choice.

The event I use is: sysLoadEvent

Post Reply