Location: Home / Lua Coding / Sample Area Old legend-1 : Mobprog
if isvisible $n
else
say Hey! Who said that?!
break
endif
say So, you wish to board?
if carries $n 22800
say I see you have a ticket to Maine. Well, all aboard!
say Don't forget to give it to the conductor when you reach your
destination.
mob transfer $n 22803
break
endif
if carries $n 22801
say I see you have a ticket to Mississippi. Well, all aboard!
say Don't forget to give it to the conductor when you reach your
destination.
mob transfer $n 22803
break
endif
if carries $n 22802
say I see you have a ticket to Texas. Well, all aboard!
say Don't forget to give it to the conductor when you reach your
destination.
mob transfer $n 22803
break
endif
if carries $n 22803
say I see you have a ticket to West Virginia. Well, all aboard!
say Don't forget to give it to the conductor when you reach your
destination.
mob transfer $n 22803
break
endif
say But you need a ticket!
New legend-1 : Lua
Note how a local function is used to replace the repeating lines in original mobprog.
--- Local function for check ticket
local function checkticket(char,objkey,dest)
if (carries(ch,objkey)) then
say ("I see you have a ticket to " .. dest .. ". Well, all aboard!")
say ("Don't forget to give it to the conductor when you reach
your destination.")
transfer(ch,"legend-3");
return true
end
return false;
end
---
--- Main Prog
---
if not(canseechar(self,ch)) then
say ("Hey! Who said that?!")
return
else
say ("So, you wish to board?")
if (checkticket(ch,"legend-0","Maine")) then return end
if (checkticket(ch,"legend-1","Mississippi")) then return end
if (checkticket(ch,"legend-2","Texas")) then return end
if (checkticket(ch,"legend-3","West Virginia")) then return end
say ("But you need a ticket!")
end
Old legend-2 : Mobprog
if room $i == 22804
say Next stop, Mississippi!
endif
if room $i == 22805
say Next stop, Texas!
endif
if room $i == 22806
say Next stop, West Virginia!
endif
if room $i == 22807
say Last stop! Everyone have their tickets ready!
endif
mob junk all.ticket
New legend-2 : Lua
Longer but more efficient - exits once correct room is found.
if (self.roomkey == "legend-4") then
say ("Next stop, Mississippi!")
purgeobj("all",LP_SEEALL+LP_CARRIEDONLY)
return
end
if (self.roomkey == "legend-5") then
say ("Next stop, Texas!")
purgeobj("all",LP_SEEALL+LP_CARRIEDONLY)
return
end
if (self.roomkey == "legend-6") then
say ("Next stop, West Virginia!")
purgeobj("all",LP_SEEALL+LP_CARRIEDONLY)
return
end
if (self.roomkey == "legend-7") then
say ("Last stop! Everyone have their tickets ready!")
purgeobj("all",LP_SEEALL+LP_CARRIEDONLY)
return
end
Old legend-3 : Mobprog
if room $i == 22804
say OK, we're here. Welcome to Maine!
mob transfer $n 22810
break
endif
say Sorry, wrong stop.
give maine $n
New legend-3 : lua
if (self.roomkey == "legend-4") then
say ("OK, we're here. Welcome to Maine!")
transfer(ch,"legend-10");
return
end
say ("Sorry, wrong stop.")
--- Returning item that triggered prog to ch, is simply:
give(obj,ch)
Old legend-4 : Mobprog
if room $i == 22805
say OK, we're here. Is this the first time you've seen the
Muddy Mississippi?
mob transfer $n 22840
break
endif
say Sorry, wrong stop.
give tick $n
New legend-4 : lua
if (self.roomkey == "legend-5") then
say ("OK, we're here. Is this the first time you've seen the
Muddy Mississippi?")
transfer(ch,"legend-40");
return
end
say ("Sorry, wrong stop.")
--- Returning item that triggered prog to ch, is simply:
give(obj,ch)
Old legend-5 : Mobprog
if room $i == 22806
say Howdy! Welcome to Texas!
mob transfer $n 22820
mob junk all
break
endif
say Sorry, wrong stop, pardner.
--- Returning item that triggered prog to ch, is simply:
give(obj,ch)
New legend-5 : lua
if (self.roomkey == "legend-6") then
say ("Howdy! Welcome to Texas!")
transfer(ch,"legend-20");
purgeobj("all",LP_CARRIEDONLY)
return
end
say ("Sorry, wrong stop, pardner.")
--- Returning item that triggered prog to ch, is simply:
give(obj,ch)
Old legend-6 : Mobprog
if room $i == 22807
say Everything seems in order. Welcome to West Virginia!
mob transfer $n 22830
mob junk all
break
endif
say Sorry, wrong stop.
give tick $n
New legend-6 : lua
if (self.roomkey == "legend-7") then
say ("Everything seems in order. Welcome to West Virginia!")
transfer(ch,"legend-30");
purgeobj("all",LP_CARRIEDONLY)
return
end
say ("Sorry, wrong stop.")
--- Returning item that triggered prog to ch, is simply:
give(obj,ch)
Old legend-8 : Mobprog
mob echo Casey reaches up and tugs on the train whistle cord.
mob echo Whooooooooooooo whooooooooooooooooo!
mob echo Whooooooooooooo whooooooooooooooooo!
mob echo Whooooooooooooo whooooooooooooooooo!
New legend-8 : lua
echo ("Casey reaches up and tugs on the train whistle cord.")
echo ("Whooooooooooooo whooooooooooooooooo!")
echo ("Whooooooooooooo whooooooooooooooooo!")
echo ("Whooooooooooooo whooooooooooooooooo!")
Old legend-9 : Mobprog
say I can't stop her!!
say Save yourself! I'll keep braking!
mob echo Casey Jones reaches over, grabs you, and throws you from
the engine.
mob transfer all 22825
New legend-9 : lua
say ("I can't stop her!!")
say ("Save yourself! I'll keep braking!")
echo ("Casey Jones reaches over, grabs you, and throws you from
the engine.")
transfer("all","legend-25",LP_PLRONLY)
Old legend-14 : Mobprog
mob echo Paul Bunyan uses a huge shovel to dig out the land
mob echo in the middle of Round River.
New legend-14 : lua
echo ("Paul Bunyan uses a huge shovel to dig out the land")
echo ("in the middle of Round River.")
Old legend-15 : Mobprog
mob echo Paul makes one final stab at the land in the middle of
mob echo Round River, digging out the soil there.
mob echo
say There! That should do it. Guess we'll have to call it Round Lake
from now on.
mob transfer all 22815
mob goto 22814
if mobhere 22815
mob purge catfish
endif
if mobhere 22811
mob purge deer
endif
if mobhere 22813
mob purge moose
endif
if mobhere 22807
mob purge lumberjack
endif
New legend-15 : lua
echo ("Paul makes one final stab at the land in the middle of")
echo ("Round River, digging out the soil there.nr")
say ("There! That should do it. Guess we'll have to call it
Round Lake from now on.")
transfer ("all","legend-15",LP_PLRONLY)
rgoto ("legend-14")
if (mobexists("legend-15",room)) then
purgemob("legend-15",LP_ALLMOBS)
end
if (mobexists("legend-11",room)) then
purgemob("legend-11",LP_ALLMOBS)
end
if (mobexists("legend-13",room)) then
purgemob("legend-13",LP_ALLMOBS)
end
if (mobexists("legend-7",room)) then
purgemob("legend-7",LP_ALLMOBS)
end
Old legend-33 : Mobprog
mob goto 22836
if objhere npc
mob purge npc
endif
mob goto 22835
New legend-33 : lua
rgoto("legend-36")
if (objhere("npc")) then
purgeobj("npc")
end
rgoto("legend-35")
Old legend-36 : Mobprog
mob echo Amazing! John Henry has beaten the machine!
mob echo
mob echo
sigh
die
mob oload 22836 0 room
mob oload 22835 0 room
mob oload 22835 0 room
mob purge $i
New legend-36 : lua
echo ("Amazing! John Henry has beaten the machine!nr")
social("sigh")
social("die")
oload("legend-36",0,"room")
oload("legend-35",0,"room")
oload("legend-35",0,"room")
purgemob(self)
Old legend-40 : Mobprog
if room $n == 22841
say Welcome aboard!
say Here's your equipment. Hop to it, pal.
mob oload 22841
give pole $n
pat $n
endif
if room $n == 22842
say Here, can you put this on your head?
say No? Darn. I'm sober enough to probably hit it.
endif
if room $n == 22843
say Once, when I was a child, I wrestled a ten foot catfish.
endif
if room $n == 22844
say Hey, when we get to port, you should come drink with us.
say It will be fun!!
endif
New legend-40 : lua
local roomkey = self.roomkey
chname = ch.name
if (roomkey == "legend-41") then
say ("Welcome aboard!")
say ("Heres your equipment. Hop to it, pal.")
--- Use the OBJ returned by oload to make sure we give the right item.
local newobj = oload ("legend-41")
give(newobj,ch)
destroy(self,"legend-41")
social("pat",ch)
return
end
if (roomkey == "legend-42") then
say ("Here, can you put this on your head?")
say ("No? Darn. I'm sober enough to probably hit it.")
return
end
if (roomkey == "legend-43") then
say ("Once, when I was a child, I wrestled a ten foot catfish.")
return
end
if (roomkey == "legend-44") then
say ("Hey, when we get to port, you should come drink with us.")
say ("It will be fun.")
end
Old legend-45 : Mobprog
mob goto 22846
mob purge sapling
mob oload 22811 0 room
mob oload 22837
put apple sap
mob goto 22849
New legend-45 : lua
rgoto("legend-46")
purgeobj("legend-11",LP_ALLOBJS+LP_SEEALL)
oload("legend-11",0,"room")
oload("legend-37")
mdo("put apple sap")
rgoto("legend-49")
Old legend-46 : Mobprog
mob goto 22838
mob purge tree
mob oload 22810 0 room
mob oload 22807
put apple tree
mob goto 22849
New legend-46 : lua
rgoto("legend-38")
purgeobj("legend-10",LP_ALLOBJS+LP_SEEALL)
oload("legend-10",0,"room")
oload("legend-7")
mdo("put apple tree")
rgoto("legend-49")
Old legend-47 : Mobprog
mob goto 22828
mob purge tree
mob oload 22810 0 room
mob oload 22806
put apple tree
mob goto 22849
New legend-47 : lua
rgoto("legend-28")
purgeobj("legend-10",LP_ALLOBJS+LP_SEEALL)
oload("legend-10",0,"room")
oload("legend-6")
mdo("put apple tree")
rgoto("legend-49")
Old legend-48 : Mobprog
mob goto 22815
mob purge tree
mob oload 22810 0 room
mob oload 22805
put apple tree
mob goto 22849
New legend-48 : lua
rgoto("legend-15")
purgeobj("legend-10",LP_ALLOBJS+LP_SEEALL)
oload("legend-10",0,"room")
oload("legend-5")
mdo("put apple tree")
rgoto("legend-49")
Old legend-49 : Mobprog
if carries $n 22805
and carries $n 22806
and carries $n 22807
and carries $n 22837
say Congratulations! You found my apple trees!
mob oload 22848
give portal $n
shakes $n
mob remove $n 22837
mob remove $n 22805
mob remove $n 22807
mob remove $n 22806
mob echo *poof*
mob transfer $n 66000
break
endif
say Sorry, you haven't found all my apple trees yet...
say Or did you eat all the apples?
heh
mob transfer $n 22800
New legend-49 : lua
if carries(ch,"legend-5") and carries(ch,"legend-6") and
carries(ch,"legend-7") and carries(ch,"legend-37") then
say("Congratulations! You found my apple trees!")
local newobj = oload("legend-48")
give(newobj,ch)
social("shakes",ch)
destroy(ch,"legend-37")
destroy(ch,"legend-5")
destroy(ch,"legend-7")
destroy(ch,"legend-6")
echo ("*poof*")
transfer(ch,"aylor-0",LP_SEEALL)
return
end
say ("Sorry, you haven't found all my apple trees yet...")
say ("Or did you eat all the apples?")
social("heh")
transfer(ch,"legend-0",LP_SEEALL)
|