I am not sure why this doesn't work

OGslinkyT
Posts: 15
Joined: Thu Sep 06, 2018 5:26 am

Re: I am not sure why this doesn't work

Post by OGslinkyT » Thu Jan 31, 2019 12:25 am

I have this code set on a perl regx trigger of " \[ obvious exits\: (.+)\ ]"
(obviously for this to work you have to have adaels's mapper script for wotmud)
Code: [show] | [select all] lua
--- this sets adjacentIDs to nil so that the variables are cleared on entering each room
wotmudmapper.adjacentIDs = nil
wotmudmapper.dlineIDnorth = nil
wotmudmapper.dlineIDsouth = nil
wotmudmapper.dlineIDeast = nil
wotmudmapper.dlineIDwest = nil
wotmudmapper.dlineIDup = nil
wotmudmapper.dlineIDdown = nil

wotmudmapper.adjacentIDs = {getRoomExits (wotmudmapper.currentID[1])}

--- if an exit exists then get the exits of the adjacent rooms
if 	table.contains(wotmudmapper.adjacentIDs[1],"north") then
  	wotmudmapper.dlineIDnorth = {getRoomExits (wotmudmapper.adjacentIDs[1].north)}
	 	end

if 	table.contains(wotmudmapper.adjacentIDs[1],"south") then
	 	wotmudmapper.dlineIDsouth = {getRoomExits (wotmudmapper.adjacentIDs[1].south)}
	 	end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"east") then
		wotmudmapper.dlineIDeast  = {getRoomExits (wotmudmapper.adjacentIDs[1].east)}
		end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"west") then
		wotmudmapper.dlineIDwest  = {getRoomExits (wotmudmapper.adjacentIDs[1].west)}
		end
		
if	table.contains(wotmudmapper.adjacentIDs[1],"down") then
		wotmudmapper.dlineIDdown  = {getRoomExits (wotmudmapper.adjacentIDs[1].down)}
		end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"up") then 
		wotmudmapper.dlineIDup    = {getRoomExits (wotmudmapper.adjacentIDs[1].up)}
		end


---- NORTH
--- sets not existing exits of adjacent rooms to 0 and existing ones to 1
	 	
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnorthnorth   = 0
		
		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"north") then 
		wotmudmapper.dlineMATHnorthnorth = 1 else
		wotmudmapper.dlineMATHnorthnorth = 0
	 	end
	 
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnorthsouth   = 0
		
		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"south") then 
	 					wotmudmapper.dlineMATHnorthsouth = 1 else
						wotmudmapper.dlineMATHnorthsouth = 0
	 			 		end
	
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnortheast   = 0
		
		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"east") then 
	 					wotmudmapper.dlineMATHnortheast = 1 else
						wotmudmapper.dlineMATHnortheast = 0
	 				 	end
	 
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnorthwest   = 0

		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"west") then 
	 					wotmudmapper.dlineMATHnorthwest = 1 else
						wotmudmapper.dlineMATHnorthwest = 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnorthup   = 0

		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"up") then 
	 					wotmudmapper.dlineMATHnorthup = 1 else
						wotmudmapper.dlineMATHnorthup = 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDnorth") == false then
	 	wotmudmapper.dlineMATHnorthdown   = 0

		elseif 	table.contains(wotmudmapper.dlineIDnorth[1],"down") then 
	 					wotmudmapper.dlineMATHnorthdown = 1 else
						wotmudmapper.dlineMATHnorthdown = 0
						end
	 
--- SOUTH

if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsouthnorth   = 0
	
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"north") then 
	 					wotmudmapper.dlineMATHsouthnorth  = 1 else
						wotmudmapper.dlineMATHsouthnorth 	= 0
						end

if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsouthsouth   = 0
		 
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"south") then 
	 					wotmudmapper.dlineMATHsouthsouth  = 1 else
						wotmudmapper.dlineMATHsouthsouth	= 0
						end

if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsoutheast   = 0
	
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"east") then 
	 					wotmudmapper.dlineMATHsoutheast = 1 else
						wotmudmapper.dlineMATHsoutheast	= 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsouthwest   = 0
	
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"west") then 
	 					wotmudmapper.dlineMATHsouthwest	= 1 else
						wotmudmapper.dlineMATHsouthwest	= 0
						end
	
if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsouthup   = 0
	
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"up") then 
	 					wotmudmapper.dlineMATHsouthup	= 1 else
						wotmudmapper.dlineMATHsouthup	= 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDsouth") == false then
	 	wotmudmapper.dlineMATHsouthdown   = 0
	
		elseif 	table.contains(wotmudmapper.dlineIDsouth[1],"down") then 
	 					wotmudmapper.dlineMATHsouthdown	= 1 else
						wotmudmapper.dlineMATHsouthdown	= 0
						end
	 
--- EAST

if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeastnorth   = 0
	 
		elseif 	table.contains(wotmudmapper.dlineIDeast[1],"north") then 
	 					wotmudmapper.dlineMATHeastnorth	= 1 else
						wotmudmapper.dlineMATHeastnorth = 0
						end
						
if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeastsouth   = 0
	 
		elseif 	table.contains(wotmudmapper.dlineIDeast[1],"south") then 
	 					wotmudmapper.dlineMATHeastsouth	= 1 else
						wotmudmapper.dlineMATHeastsouth	= 0
						end
	
if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeasteast   = 0
	 
	 	elseif 	table.contains(wotmudmapper.dlineIDeast[1],"east") then 
	 					wotmudmapper.dlineMATHeasteast	= 1 else
						wotmudmapper.dlineMATHeasteast	= 0
	 					end

if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeastwest   = 0
	 	 
		elseif 	table.contains(wotmudmapper.dlineIDeast[1],"west") then 
	 					wotmudmapper.dlineMATHeastwest  = 1 else
						wotmudmapper.dlineMATHeastwest	= 0
						end

if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeastup   = 0
	 
		elseif 	table.contains(wotmudmapper.dlineIDeast[1],"up") then 
	 					wotmudmapper.dlineMATHeastup	  = 1 else
						wotmudmapper.dlineMATHeastup		= 0
	 		 			end

if  table.contains(wotmudmapper,"dlineIDeast") == false then
	 	wotmudmapper.dlineMATHeastdown   = 0
	 	 
		elseif 	table.contains(wotmudmapper.dlineIDeast[1],"down") then 
	 					wotmudmapper.dlineMATHeastdown  = 1 else
						wotmudmapper.dlineMATHeastdown	= 0
						end
	 
--- WEST

if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwestnorth   = 0	

		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"north") then 
	 					wotmudmapper.dlineMATHwestnorth  	= 1 else
						wotmudmapper.dlineMATHwestnorth 	=0
						end

if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwestsouth   = 0		 
		
		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"south") then 
	 					wotmudmapper.dlineMATHwestsouth  	= 1 else
						wotmudmapper.dlineMATHwestsouth		= 0
						end

if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwesteast   = 0		
		
		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"east") then 
	 					wotmudmapper.dlineMATHwesteast  = 1 else
						wotmudmapper.dlineMATHwesteast	= 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwestwest   = 0	
		
		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"west") then 
	  				wotmudmapper.dlineMATHwestwest  = 1 else
						wotmudmapper.dlineMATHwestwest	= 0
						end

if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwestup   = 0	
		
		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"up") then 
	  				wotmudmapper.dlineMATHwestup  = 1 else
						wotmudmapper.dlineMATHwestup	= 0
						end

if  table.contains(wotmudmapper,"dlineIDwest") == false then
	 	wotmudmapper.dlineMATHwestdown   = 0		 

		elseif 	table.contains(wotmudmapper.dlineIDwest[1],"down") then 
	 					wotmudmapper.dlineMATHwestdown  = 1 else
						wotmudmapper.dlineMATHwestdown	= 0
						end
	 
--- UP

if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupnorth   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"north") then 
	 					wotmudmapper.dlineMATHupnorth  	= 1 else
						wotmudmapper.dlineMATHupnorth		= 0
						end
if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupsouth   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"south") then 
	 					wotmudmapper.dlineMATHupsouth  	= 1 else
						wotmudmapper.dlineMATHupsouth		= 0
						end
	
if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupeast   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"east") then 
	 					wotmudmapper.dlineMATHupeast  = 1 else
						wotmudmapper.dlineMATHupeast	= 0
						end

if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupwest   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"west") then 
	 					wotmudmapper.dlineMATHupwest  = 1 else
						wotmudmapper.dlineMATHupwest	= 0
						end
	 
if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupup   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"up") then 
	 					wotmudmapper.dlineMATHupup  = 1 else
						wotmudmapper.dlineMATHupup	= 0
						end

if  table.contains(wotmudmapper,"dlineIDup") == false then
	 	wotmudmapper.dlineMATHupdown   = 0	
			 
		elseif 	table.contains(wotmudmapper.dlineIDup[1],"down") then 
	 					wotmudmapper.dlineMATHupdown  = 1 else
						wotmudmapper.dlineMATHupdown	=	0
						end
		
--- DOWN
	 
if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdownnorth   = 0	 	 	
		
		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"north") then 
	 					wotmudmapper.dlineMATHdownnorth  	= 1 else
						wotmudmapper.dlineMATHdownnorth		= 0
						end

if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdownsouth   = 0	
			 	 
		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"south") then 
	 					wotmudmapper.dlineMATHdownsouth  	= 1 else
						wotmudmapper.dlineMATHdownsouth		= 0
						end

if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdowneast   = 0		
		
		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"east") then 
	 					wotmudmapper.dlineMATHdowneast  	= 1 else
						wotmudmapper.dlineMATHdowneast		= 0
						end

if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdownwest   = 0	
		
		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"west") then 
	 					wotmudmapper.dlineMATHdownwest  = 1 else
						wotmudmapper.dlineMATHdownwest	= 0
						end

if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdownup   = 0		 

		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"up") then 
	 					wotmudmapper.dlineMATHdownup  = 1 else
						wotmudmapper.dlineMATHdownup	= 0
						end

if  table.contains(wotmudmapper,"dlineIDdown") == false then
	 	wotmudmapper.dlineMATHdowndown   = 0	
		
		elseif 	table.contains(wotmudmapper.dlineIDdown[1],"down") then 
	 					wotmudmapper.dlineMATHdowndown  = 1 else
						wotmudmapper.dlineMATHdowndown	= 0
						end
		



		
	 
Then as a child trigger to the previous trigger with the same perl regex \[ obvious exits\: (.+)\ ]
Code: [show] | [select all] lua
local exitnumber	= table.size(wotmudmapper.adjacentIDs[1])

local east 	= 	wotmudmapper.dlineMATHnortheast 
							+	wotmudmapper.dlineMATHeasteast 
							+ wotmudmapper.dlineMATHsoutheast
							+ wotmudmapper.dlineMATHwesteast
							+ wotmudmapper.dlineMATHupeast
							+	wotmudmapper.dlineMATHdowneast

local west 	= 	wotmudmapper.dlineMATHnorthwest 
							+	wotmudmapper.dlineMATHeastwest
							+ wotmudmapper.dlineMATHsouthwest
							+ wotmudmapper.dlineMATHwestwest
							+ wotmudmapper.dlineMATHupwest
							+	wotmudmapper.dlineMATHdownwest

local north	= 	wotmudmapper.dlineMATHnorthnorth
							+	wotmudmapper.dlineMATHeastnorth
							+ wotmudmapper.dlineMATHsouthnorth
							+ wotmudmapper.dlineMATHwestnorth
							+ wotmudmapper.dlineMATHupnorth
							+	wotmudmapper.dlineMATHdownnorth

local south =		wotmudmapper.dlineMATHnorthsouth 
							+	wotmudmapper.dlineMATHeastsouth 
							+ wotmudmapper.dlineMATHsouthsouth
							+ wotmudmapper.dlineMATHwestsouth
							+ wotmudmapper.dlineMATHupsouth
							+	wotmudmapper.dlineMATHdownsouth

local up	  =		wotmudmapper.dlineMATHnorthup
							+	wotmudmapper.dlineMATHeastup 
							+ wotmudmapper.dlineMATHsouthup
							+ wotmudmapper.dlineMATHwestup
							+ wotmudmapper.dlineMATHupup
							+	wotmudmapper.dlineMATHdownup

local down  =		wotmudmapper.dlineMATHnorthdown 
							+	wotmudmapper.dlineMATHeastdown
							+ wotmudmapper.dlineMATHsouthdown
							+ wotmudmapper.dlineMATHwestdown
							+ wotmudmapper.dlineMATHupdown
							+	wotmudmapper.dlineMATHdowndown
							

local percentN = north/exitnumber
local percentS = south/exitnumber
local percentE = east/exitnumber
local percentW = west/exitnumber
local percentU = up/exitnumber
local percentD = down/exitnumber

if 	table.contains(wotmudmapper.adjacentIDs[1],"south") or
		percentN == 0 then
		northlabel:echo (" X ") else
		northlabel:echo (string.format("%2.2f",percentN))
		end

if 	table.contains(wotmudmapper.adjacentIDs[1],"north") or
		percentS == 0 then
		southlabel:echo (" X ") else		
		southlabel:echo (string.format("%2.2f",percentS))
		end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"west") or
		percentE == 0 then
		eastlabel:echo (" X ") else
		eastlabel:echo (string.format("%2.2f",percentE))
		end
		

if 	table.contains(wotmudmapper.adjacentIDs[1],"east") or	
		percentW == 0 then
		westlabel:echo (" X ") else
		westlabel:echo (string.format("%2.2f",percentW))
		end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"down") or
		percentU == 0 then 
		uplabel:echo (" X ") else
		uplabel:echo (string.format("%2.2f",percentU))
		end
		
if 	table.contains(wotmudmapper.adjacentIDs[1],"up") or
		percentD == 0 then
		downlabel:echo (" X ") else
		downlabel:echo (string.format("%2.2f",percentD))
		end
then I made a simple compass picture
mudlet_compass.png
mudlet_compass.png (3.37 KiB) Viewed 69 times
and made a label for the compass picture and then smaller labels next to the corresponding directions for each d line %

User avatar
Vadi
Posts: 4641
Joined: Sat Mar 14, 2009 3:13 pm

Re: I am not sure why this doesn't work

Post by Vadi » Fri Feb 01, 2019 6:27 am

Nice work!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests