How can I prevent players to type object numbers?

4 views
Skip to first unread message

Daniel Villalon

unread,
Jan 27, 2017, 8:53:52 AM1/27/17
to MOO Talk
Hello.
I'm developing a new project bassed on MOO Principles, but i need that when my players type something in the parser, they can't reffer directly to object reference numbers. For example,:
An elevator has the reference number #217 in the database, and, when the players types enter enter #217 from any location, they can enter from any part of the MOO. I want to prevent this, leting only this posibility to wizards and programmers.
I know, with a little code put in every verb I can limit this behavior, but i want some optimization at programming and not put a code in every verb limiting this. I supose that i can do this through #56:object_match_failed, but i don't find a workaround. Can somebody help me please?
I'm using LambdaCore Database. Sorry for my english, is'nt my main language.

Thanks!

Dgleks

unread,
Feb 2, 2017, 8:44:29 PM2/2/17
to MOO Talk
Hello,
I have just the thing for you! I actually did this exact same thing on a game I ran back in the day, so I'll paste the code below. If you can't seem to see it here, or if you have any issues, feel free to reply here and we can setup another way that I'll get it working for you. Thanks!
@prog #51:match
":match(string, object-list)";
"Return object in 'object-list' aliased to 'string'.";
"Matches on a wide variety of syntax, including:";
" \"5th axe\" -- The fifth object matching \"axe\" in the object list.";
" \"where's sai\" -- The only object contained in 'where' matching \"sai\" (possible $ambiguous_match).";
" \"where's second staff\" -- The second object contained in 'where' matching \"staff\".";
" \"my third dagger\" -- The third object in your inventory matching \"dagger\".";
"Ordinal matches are determined according to the match's position in 'object-list' or, if a possessive (such as \"where\" above) is given, then the ordinal is the nth match in that object's inventory.";
"In the matching room (#3879@LambdaMOO), the 'object-list' consists of first the player's contents, then the room's, and finally all exits leading from the room.";
{string, olist} = args;
if (!string)
  return $nothing;
elseif (string == "me" && player in olist)
  return player;
elseif (string == "here" && player.location in olist)
  return player.location;
  "Don't match obj numbers, unless host...";
elseif (valid(object = $string_utils:literal_object(string)) && $object_utils:isa(player, $frand_class))
  return object;
elseif (valid(object = $string_utils:match(string, olist, "aliases")))
  return object;
elseif (parsed = this:parse_ordinal_reference(string))
  return this:match_nth(parsed[2], olist, parsed[1]);
elseif (parsed = this:parse_possessive_reference(string))
  {whostr, objstr} = parsed;
  if (valid(whose = this:match(whostr, olist)))
    return this:match(objstr, whose.contents);
  else
    return whose;
  endif
elseif (valid(object = this:match_nth(string, olist, 1)))
  return object;
else
  return object;
endif
"Profane (#30788) - Sat Jan  3, 1998 - Changed so literals get returned ONLY if in the passed object list.";
"Profane (#30788) - Sat Jan  3, 1998 - OK, that broke lots of stuff, so changed it back.";

Daniel Villalon

unread,
Feb 5, 2017, 9:41:49 AM2/5/17
to MOO Talk
OK, the code works only with verbs that call some type of match. This code does'nt work with verbs without match. FOr example, if i type look #3 being a palyer the code works, but not with enter #147, because this verb does'nt use any kind of match.

Daniel Villalon

unread,
Feb 5, 2017, 9:41:49 AM2/5/17
to MOO Talk
Thanks! The code works perfectly.

Now i'm searching another thing. I need to work with ambiguous objects. For example, if i have two pizzas in my inventory, when i type eat pizza, the moo says 'I don't understand that. pizza is an ambiguous name.'

I need something similar to, eat 1.pizza or 2.pizza to get this work, but without breaking the code you gave me.

Is posible? Thanks a lot!




El viernes, 27 de enero de 2017, 14:53:52 (UTC+1), Daniel Villalon escribió:

Michael Munson

unread,
Feb 6, 2017, 1:50:07 AM2/6/17
to Daniel Villalon, MOO Talk
It is possible, but it is a lot more complicated than you'd think. If your use case is a VR RPG type thing, then you may consider starting from a core/database that has much of this functionality included.


I would recommend HellCore based on HellMOO (http://hellmoo.org/wiki/index.php/HellCore), it has ordinal matching built in and it works exactly as you describe you want. 1.pizza, 2.pizza, etc.


--
You received this message because you are subscribed to the Google Groups "MOO Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to MOO-talk+unsubscribe@googlegroups.com.
To post to this group, send email to MOO-...@googlegroups.com.
Visit this group at https://groups.google.com/group/MOO-talk.
For more options, visit https://groups.google.com/d/optout.

Daniel Villalon

unread,
Feb 6, 2017, 8:58:05 AM2/6/17
to MOO Talk
Interesting, but i created a lot of things on lambdacore and i don't want to start all over. Can I MIGRATE in some way the content of my lambdacore (Areas and object areas) to HellCore?

THanks for all!


El viernes, 27 de enero de 2017, 14:53:52 (UTC+1), Daniel Villalon escribió:

KJ

unread,
Feb 6, 2017, 2:42:29 PM2/6/17
to MOO Talk
I have had some success porting objects and utilities verbs from the RPG core.
You can check out the internals  of RPG core using the Moo Inspector here:
http://brn227.brown.wmich.edu/seafarer/MOO%20inspector/index.html
There may be some useful ideas in the other cores listed there too.
Ciao
KJ

Dgleks

unread,
Feb 6, 2017, 2:52:00 PM2/6/17
to MOO Talk
You absolutely don't need to switch cores. It's really simple, you need to do eat first pizza, eat second pizza, etc. Additionally you can also do eat my first pizza eat my second pizza to only match with items in your inventory. The match verb's comments explain do a pretty good job at explaining this.

Daniel Villalon

unread,
Feb 7, 2017, 11:28:16 AM2/7/17
to MOO Talk
Yes dgleks, your command should work, but i noticed something.

A friend of mine are developing a similar project, but he's running a gamamoo server. In this server your code works perfectly. In lambdamoo the server ignores completely this part.

The reason wich i'm not using gamamoo server is because i patched the lambdamoo server with the UTF8 encoding because the spanish language uses some special characters like tildes (á, é, í, ó, ú) and ñ letter and when I try to modify a verb with the verb editor the gama server breaks the code with this specials characters for an unknown reason, and this is strange because the gamamoo has the UTF8 by default.

Actually i'm using lambdamoo server 1.8.1. I show you the input.

@version
The MOO is currently running version 1.8.1u4 of the LambdaMOO server code.
The database was derived from a core created on May 18, 2004 at LambdaMOO for version 1.8.1w2 of the server.

Is any more recent version solving this problem? The other alternative is running my moo in gamamoo server without tildes and ñ's, but this is a not good practice and not language atractive to the players.

Thanks for all.



El viernes, 27 de enero de 2017, 14:53:52 (UTC+1), Daniel Villalon escribió:
Reply all
Reply to author
Forward
0 new messages