Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapper: (code incl.) Manual Cexit Creation #151

Closed
fiendish opened this issue Feb 14, 2014 · 3 comments
Closed

Mapper: (code incl.) Manual Cexit Creation #151

fiendish opened this issue Feb 14, 2014 · 3 comments

Comments

@fiendish
Copy link
Owner

From pierid...@gmail.com on September 16, 2011 07:36:44

(based on r1340 snapshot)
(modified from functions custom_exit and map_goto)

I tested this for me and it works, or seems to at least. You actually know the code so you might see anything I've screwed up.

(ISSUES: Some error-checking code missing; "rooms"-updating line messed up (see comments))

mapper cexit_manual <entry_vnum> <exit_vnum>
--> Manually link a custom exit by room IDs
> (ex: 'mapper cexit_manual 12345 12356 ride bucket')

                    > To insert a pause during execution

                    > of the cexit, use wait(<seconds>) as one

                    > or more of the cexit moves

<alias
match="^mapper cexit_manual ([^ ]+) ([^ ]+) (.+)$"
enabled="y"
sequence="100"
script="manual_custom_exit"
regexp="y"

-- manual_custom_exit function modified from contribution by Spartacus
function manual_custom_exit (name, line, wildcards)

local cexit_command = wildcards [3] or ""

if cexit_command == "" then
world.Note("Nothing to do!")
return
end -- if cexit_command

local remap = {
n = "north",
w = "west",
s = "south",
e = "east",
u = "up",
d = "down"
}

-- the current system makes standard letter exit (n,e,s,w,d,u) cexits not usable, so remap them
-- to their long word forms
if remap[cexit_command] then
cexit_command = remap[cexit_command]
end

local cexit_start = string.match(wildcards[1], "^(nomap_.+)$") or tonumber(wildcards [1])
if not cexit_start or (type(cexit_start) == "number" and cexit_start < 0) then
world.Note("The manual cexit command expects a room id as its first input.")
return
end

-- if <cexit_start doesn't exist> then
-- world.Note( "Room " .. cexit_start .. " has not yet been mapped." )
-- return
-- elseif <cexit_start is a maze> then
-- world.Note( "CEXIT FAILED: You cannot link custom exits from unmappable rooms." )
-- return
-- end

local cexit_end = string.match(wildcards[2], "^(nomap_.+)$") or tonumber(wildcards [2])
if not cexit_end or (type(cexit_end) == "number" and cexit_end < 0) then
world.Note("The manual cexit command expects a room id as its second input.")
return
end

-- if <cexit_end doesn't exist> then
-- world.Note( "Room " .. cexit_end .. " has not yet been mapped." )
-- return
-- elseif <cexit_end is a maze> then
-- world.Note( "CEXIT FAILED: You cannot link custom exits to unmappable rooms." )
-- return
-- end

if cexit_start == cexit_end then
world.Note( "CEXIT FAILED: You cannot link a room to itself." )
return
end

world.Note (string.format("Custom Exit CONFIRMED: %s (%s) -> %s", cexit_start, cexit_command, cexit_end))
dbcheck (db:execute (string.format ([[
INSERT OR REPLACE INTO exits (dir, fromuid, touid, date_added)
VALUES (%s, %s, %s, DATETIME('NOW'));
]], fixsql (string.lower(cexit_command)), -- direction (eg. "n")
fixsql (cexit_start), -- source room
fixsql (cexit_end) -- sink room
)))
-- (This line gives an error, but I'm not sure why.
-- The cexit is still created and saved fine, as far as I can tell,
-- so I don't know what leaving this out breaks.)
-- rooms[cexit_start].exits[cexit_command] = cexit_end

end -- manual_custom_exit

Original issue: http://code.google.com/p/aardwolfclientpackage/issues/detail?id=151

@fiendish
Copy link
Owner Author

From Fiendi...@gmail.com on September 21, 2011 09:51:03

Issue 149 has been merged into this issue.

@fiendish
Copy link
Owner Author

From Fiendi...@gmail.com on October 22, 2011 10:01:44

Labels: Component-mapper

@fiendish
Copy link
Owner Author

From pierid...@gmail.com on March 03, 2013 10:20:16

In case anyone comes across this, I just wanted to mention that I just tried this in r1748 and it still seems to work (with the same caveat as before that I've not been able to test/check it thoroughly for correctness).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant