@create Generic Sittable named Generic Climbable Object:Generic Climbable Object,Climbable @prop "Generic Climable"."copyright" "Generic Climbable written by yduJ@LambdaMOO summer 91" @prop "Generic Climbable"."capacity" 1 r @prop "Generic Climbable"."step-down_msg" "You descend the %d." rc @prop "Generic Climbable"."ostep-down_msg" "descends the %d." rc @prop "Generic Climbable"."descriptions" {} r @prop "Generic Climbable"."height" 1 r @prop "Generic Climbable"."ostop-climbing_msg" "gets off the %d." rc @prop "Generic Climbable"."stop-climbing_msg" "You get off the %d." rc @prop "Generic Climbable"."next-step_msg" "You climb up." rc @prop "Generic Climbable"."onext-step_msg" "climbs up the %d." rc @prop "Generic Climbable"."ostart-climbing_msg" "climbs onto the %d." rc @prop "Generic Climbable"."start-climbing_msg" "You climb onto the %d." rc @prop "Generic Climbable"."climber_location" {} r ;"Generic Climbable".("key") = 0 ;"Generic Climbable".("aliases") = {"Generic Climbable Object", "Climbable"} ;"Generic Climbable".("description") = {"The generic climbable is a limited sort of multiroom.", "Players climb onto and up it with 'climb climbable', and descend with 'descend climbable'.", "@height climbable is : Defines the maximum height of a climbable.", " Used by the climb verb to detect when you can't go any further.", "@describe climbable at level as string : Defines a single line description", " to be printed to the player when e climbs or descends to that level, or", " to be appended to the output of the containing room's :look_self when ", " executed by the player. (This is an awful kluge. Don't read the code, OK?)", " No editing is available; you may only replace strings with @describe again.", "@capacity climbable is : Defines the maximum number of people who ", " can be climbing on the climbable at once.", "", "@messages available to set:", " @next-step climbable is \"You climb up.\"", " @onext-step climbable is \"climbs up the %d.\"", "Printed to player and room (respectively) when someone climbs from one level to the next.", " @start-climbing climbable is \"You climb onto the %d.\"", " @ostart-climbing climbable is \"climbs onto the %d.\"", "Printed to player and room (respectively) when someone climbs onto the climbable for the first time.", " @step-down climbable is \"You descend the %d.\"", " @ostep-down climbable is \"descends the %d.\"", "Printed to player and room (respectively) when someone descends from one level to the previous.", " @stop-climbing climbable is \"You get off the %d.\"", " @ostop-climbing climbable is \"gets off the %d.\"", "Printed to player and room (respectively) when someone descends from the bottom level to the floor", "", "Programmatic Customization:", "The verb :look_height is called in all places where the climbable wants to print out one of the height descriptions entered with @describe above. This verb does player:tell; it doesn't return its string or anything. You can override it, or add stuff to it.", "", "The verb :set_description(level,description) is used by the @describe verb, and can be used to set multiline descriptions by making the second argument a list."} @verb "Generic Climbable":"climb" this none none @program "Generic Climbable":climb if (where = (player in this.sitting)) if ((ht = this.climber_location[where]) >= this.height) player:tell("You are already at the top of ", this.name, "."); else player:tell($string_utils:pronoun_sub(this.("next-step_msg"))); player.location:announce(player.name, " ", $string_utils:pronoun_sub(this.("onext-step_msg"))); this.climber_location = listset(this.climber_location, ht + 1, where); this:look_height(ht + 1); endif elseif (length(this.sitting) >= this.capacity) player:tell("You can't climb; it looks like ", this.name, " is full."); else this:add_sitter(player, 1); player:tell($string_utils:pronoun_sub(this.("start-climbing_msg"))); player.location:announce(player.name, " ", $string_utils:pronoun_sub(this.("ostart-climbing_msg"))); this:look_height(1); endif . @verb "Generic Climbable":"desc*end" this none none @program "Generic Climbable":descend if (where = (player in this.sitting)) if ((ht = this.climber_location[where]) == 1) player:tell($string_utils:pronoun_sub(this.("stop-climbing_msg"))); player.location:announce(player.name, " ", $string_utils:pronoun_sub(this.("ostop-climbing_msg"))); this:set_sitting(listdelete(this.sitting, where)); this.climber_location = listdelete(this.climber_location, where); else player:tell($string_utils:pronoun_sub(this.("step-down_msg"))); player.location:announce(player.name, " ", $string_utils:pronoun_sub(this.("ostep-down_msg"))); this.climber_location = listset(this.climber_location, ht - 1, where); this:look_height(ht - 1); endif else player:tell("You're not on the ", this.name, "."); endif . @verb "Generic Climbable":"sweep" this none this @program "Generic Climbable":sweep orig = this.sitting; pass(@args); diff = orig; for x in (this.sitting) diff = setremove(diff, x); endfor newlocs = {}; for x in [1..length(orig)] if (!(orig[x] in diff)) newlocs = {@newlocs, this.climber_location[x]}; endif endfor this.climber_location = newlocs; . @verb "Generic Climbable":"look_height" this none this @program "Generic Climbable":look_height if (args[1] <= length(this.descriptions)) if (typeof(desc = this.descriptions[args[1]]) == LIST) player:tell_lines(desc); else player:tell(desc); endif also = {}; for i in [1..length(this.climber_location)] if (args[1] == this.climber_location[i]) also = {@also, this.sitting[i]}; endif endfor if (also = setremove(also, player)) player:tell("You see ", #4445:list_title(also), " here as well."); endif endif . @verb "Generic Climbable":"description" this none this @program "Generic Climbable":description basic = pass(@args); return (typeof(basic) == LIST) ? {@basic, this:sitting_string("climbing")} | (basic + this:sitting_string("climbing")); . @verb "Generic Climbable":"@describe" this at any @program "Generic Climbable":@describe "@describe climbable at level as description"; if (!$perm_utils:controls(player, this)) player:tell("You must own this object to change its descriptions."); endif iargs = $string_utils:words(iobjstr); if (length(iargs) < 3) player:tell("Usage: @describe ", this.name, " at as "); endif level = tonum(iargs[1]); prep = iargs[2]; if ((!level) || (prep != "as")) player:tell("Usage: @describe ", this.name, " at as "); elseif (level > this.height) player:tell("Change the height first: ", level, " > ", this.height, "."); else iargs = iargs[3..length(iargs)]; descstr = $string_utils:from_list(iargs, " "); this:set_description(level, descstr); player:tell("You set the description of ", this.name, " at level ", level, "."); endif . @verb "Generic Climbable":"@height" this is any rd @program "Generic Climbable":@height height = tonum(iobjstr); if (!$perm_utils:controls(player, this)) player:tell("Permission denied."); elseif (height > 0) this.height = height; player:tell("Height changed to ", this.height, "."); else player:tell("Usage: @height ", this.name, " is "); endif . @verb "Generic Climbable":"set_description" this none this @program "Generic Climbable":set_description "climbable:set_description(level,desc)"; if (!$perm_utils:controls(valid(caller_perms()) ? caller_perms() | player, this)) return E_PERM; elseif (length(args) != 2) return E_ARGS; else level = args[1]; desc = args[2]; "If this is a level above any we've described before, fill in the extras with blank descs. If this is one we've commented before, the for loop will terminate because it'll be (e.g.) for x in [1..-2]."; for x in [1..level - length(this.descriptions)] this.descriptions = {@this.descriptions, ""}; endfor this.descriptions = listset(this.descriptions, desc, level); endif . @verb "Generic Climbable":"title" this none this @program "Generic Climbable":title if ($list_utils:assoc("tell_contents", callers(), 2)) if (player in this.sitting) fork (0) this:look_height(this.climber_location[player in this.sitting]); endfork endif endif return pass(@args); . @verb "Generic Climbable":"@capacity" this is any rd @program "Generic Climbable":@capacity capacity = tonum(iobjstr); if (!$perm_utils:controls(player, this)) player:tell("Permission denied."); elseif (capacity > 0) this.capacity = capacity; player:tell("Capacity changed to ", this.capacity, "."); else player:tell("Usage: @capacity ", this.name, " is "); endif . @verb "Generic Climbable":"add_sitter" this none this @program "Generic Climbable":add_sitter "Add a sitter args[1] at height args[2]."; this:set_sitting({@this.sitting, args[1]}); this.climber_location = {@this.climber_location, args[2]}; .