YASSE Walkto (script)

From Elanthipedia
Jump to: navigation, search
YASSE Walkto (script)
Category travel
Front-end YASSE
Author Antendren


Description

Script for using the walkto command.

The script will attempt to walk you to the specified room, using one type-ahead line for speed. If the walk gets stuck, the script will attempt to recover by moving one room at random and trying again. If there are no obvious exits, the script will try a direction at random. Will retreat from critters automatically.

Syntax

Run the script as <scriptname> <room>. Room can either be a (partial) room name or a room number (room names which are entirely numerical will not be properly handled).

set predefined on
setvariable walkttype "name"

setvariable temp %1
calculate temp replace 0 with ""
calculate temp replace 1 with ""
calculate temp replace 2 with ""
calculate temp replace 3 with ""
calculate temp replace 4 with ""
calculate temp replace 5 with ""
calculate temp replace 6 with ""
calculate temp replace 7 with ""
calculate temp replace 8 with ""
calculate temp replace 9 with ""

if $temp$ eq ""
	setvariable walkttype "room"


WALKTO:
	getinfo status
	if %result and %kneeling
		gosub STAND
	if %result and %prone
		gosub STAND
	if %result and %sitting
		gosub STAND

	move look

	speed fast
	match REACHED *  Stopped walking, target reached.  *
	match END Automapper: But you are already there!
	match MOVE Automapper: Automapper is unable to validate your current location.
	match MOVE Automapper is unable to find a clear path to that room
	match BLOCKED *  Stopped walking, something's blocking you.  *
	match MOVE You are engaged to a
	match MOVE You try to move, but you're engaged.
	put look
	if $walkttype$ eq "room"
		command -walkto room %1
	else
		command -walkto name "%1"
	matchwait


##


MOVE:
	speed normal
	setvariable exits ""
	counter set 0
	setvariable temp %roomdescription
	calculate temp pos obvious
	calculate temp right %result
	if %temp contains "north,"
		begin
		setvariable exits "$exits$ n"
		counter inc
		end
	if %temp contains "north."
		begin
		setvariable exits "$exits$ n"
		counter inc
		end
	if %temp contains "south,"
		begin
		setvariable exits "$exits$ s"
		counter inc
		end
	if %temp contains "south."
		begin
		setvariable exits "$exits$ s"
		counter inc
		end
	if %temp contains " east"
		begin
		setvariable exits "$exits$ e"
		counter inc
		end
	if %temp contains " west"
		begin
		setvariable exits "$exits$ w"
		counter inc
		end
	if %temp contains "northeast"
		begin
		setvariable exits "$exits$ ne"
		counter inc
		end
	if %temp contains "southeast"
		begin
		setvariable exits "$exits$ se"
		counter inc
		end
	if %temp contains "northwest"
		begin
		setvariable exits "$exits$ nw"
		counter inc
		end
	if %temp contains "southwest"
		begin
		setvariable exits "$exits$ sw"
		counter inc
		end
	if %temp contains " out"
		begin
		setvariable exits "$exits$ out"
		counter inc
		end

	action "You are engaged to a" goto RETR

	if $exits$ eq "" goto NO-EXITS

MOVE-1:
	counter rnd %c
	getword %c $exits$
	put %w
	pausetext 3 "Obvious"
	action "You are engaged to a" clear
	goto WALKTO

RETR:
	put retreat
	goto MOVE-1

NO-EXITS:
	setvariable exits "n nw w sw s se e ne u d o"
	counter set 11
	goto MOVE-1


##


BLOCKED:
	command -clear commands
	goto MOVE


##


STAND:
	match RETURN You stand
	match RETURN You are already standing
	match STAND cannot manage to stand.
	match STAND The weight of all your possessions
	put stand
	matchwait


##


RETURN:
	return


##


REACHED:
	if $walkttype$ eq "name" goto END
	if %roomnumber == %1 goto END
	pause 2
	goto REACHED
END:
	exit
Personal tools
SUPPORT ELANTHIPEDIA