22 Feb, ’18

Mushcode Waiter

by Cal

The code for my waiter bot script! Written to run in TinyMUX, using the Places system. It's designed to work with the Money System from NarniaMUSH, but that can be easily tweaked to work with any money system where you can give an object an arbitrary amount of money. It also works as-is to use as a parent object.

Players need to be sitting at a place to call over a waiter. Once the waiter comes over to a table, anyone at that table can order. Bills are on an individual basis and there is currently no way to combine or pay for another person's bill directly.

@create Waiter
@startup Waiter=@drain me; @notify me; &waiting-on me=

@@ Players need to be sitting at a place to call over a waiter.

&flag-staff Waiter=$+waiter:@if [whichplace([where(%#)],%#)]={@remit [where(%#)]= %N waves for a waiter.; @wait me={&waiting-on me=[whichplace([where(%#)],%#)]; @wait 1=@trigger me/take-orders}},@pemit %#=You should sit down at a table first.

@@ Once the waiter comes to a table, anyone at that table can order.

&take-orders Waiter=@remit [where(%#)]= [name(me)] goes over to [placeinfo([where(%#)],[v(waiting-on)],name)].;@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] says, "[v(table-greet)]";@wait me/30={@if [hasattr(me,order-[v(waiting-on)])]={@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] says, "[v(order-conf)]";@trigger me/serve-q=[v(waiting-on)];@remit [where(%#)]= [name(me)] leaves [placeinfo([where(%#)],[v(waiting-on)],name)].;&waiting-on me=; @notify me},{@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] says, "[v(order-cancel)]";@remit [where(%#)]= [name(me)] leaves [placeinfo([where(%#)],[v(waiting-on)],name)].;&waiting-on me=; @notify me}}
&place-order Waiter=$+order *:@if [strmatch([v(waiting-on)],[whichplace([where(%#)],%#)])]={@pemit/list [atplace([where(%#)],[v(waiting-on)])]=%N orders the %0.; @if [match([v(menu)], %0, |)]={@if [hasattr(me,order-[v(waiting-on)])]={&order-[v(waiting-on)] me=[v(order-[v(waiting-on)])] and [index([v(menu-desc)],|,[match([v(menu)], %0, |)],1)];&bill-%# me=[add([v(bill-%#)],[index([v(menu-cost)],|,[match([v(menu)], %0, |)],1)])]},{&order-[v(waiting-on)] me=[index([v(menu-desc)],|,[match([v(menu)], %0, |)],1)];&bill-%# me=[index([v(menu-cost)],|,[match([v(menu)], %0, |)],1)]};@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] jots down the order.}, @pemit/list [atplace([where(%#)],[v(waiting-on)])]={[name(me)] says, "Sorry, we don't have that. How about the [pickrand([v(menu)],|)]?"}},@pemit %#=There isn't anyone here to take your order. Try calling for a %xh+waiter%xn.

&serve-q Waiter=@wait 30=@wait me={&waiting-on me=%0;@trigger me/serve-orders}
&serve-orders Waiter=@remit [where(%#)]=[name(me)] goes over to [placeinfo([where(%#)],[v(waiting-on)],name)].;@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] says, "[v(serve-greet)]";@pemit/list [atplace([where(%#)],[v(waiting-on)])]=[name(me)] places [v(order-[v(waiting-on)])] on the table.;&order-[v(waiting-on)] me=;@wait 3={@remit [where(%#)]= [name(me)] leaves [placeinfo([where(%#)],[v(waiting-on)],name)].;&waiting-on me=;@notify me}

@@ Bills are on an individual basis and there is currently no way
@@ to combine or pay for another person's bill directly.

&get-check Waiter=$+check please:@if [hasattr(me,bill-%#)]=@pemit %#=You currently owe [v(bill-%#)] Clovers.,@pemit %#=You don't have a bill to pay.

@@ This section is for the money system I'm using, which is the one posted on
@@ mushcode.com from NarniaMUSH. If you're using another system, just change
@@ the variables, commands etc. below accordingly
&MCost Waiter=-1000
&MAPay Waiter=@if [hasattr(me,bill-%#)]={@switch %0=[v(bill-%#)],{@pemit %#=You have paid your bill.;&bill-%# me=},>[v(bill-%#)],{@pemit %#=You have paid your bill.;$give %#=[sub(%0,[v(bill-%#)])];&bill-%# me=},{&bill-%# me=[sub([v(bill-%#)],%0)];@pemit %#=Thank you. You still owe [v(bill-%#)] Clovers though.}},{@pemit %#=What are you trying to pay for? You haven't ordered anything.;$give %#=%0}

@@ Customize your waiter and menu items!
&table-greet Waiter=What can I get for you?
&order-conf Waiter=I'll get those orders right in for you!
&order-cancel Waiter=Not ready yet? Take your time, call me again when you're ready to order.
&serve-greet Waiter=Here you go!
&menu Waiter=pizza|cake|beer
&menu-desc Waiter=a large slice of pizza|a slice of chocolate cake|a mug of beer
&menu-cost Waiter=10|5|3
@desc Waiter=A cheerful waiter, ready to take your order.