another property?

0 views
Skip to first unread message

johnny

unread,
Dec 18, 2009, 7:02:52 PM12/18/09
to moo-...@googlegroups.com
Ok here is the question and here is the code i have but not sure where i would put the code to ask if the item is being used or not.
 
here is the code  1: this.blending = 1;
  2: if (dobjstr == "1")
  3:   player:tell("Please stand by for your drink to be blended.");
  4:   player.location:announce_all("A voice on the blender says please stand by while your drink is being blended.");
  5:   suspend(15);
  6:   OBJ = create($drink, #-1);
  7:   OBJ.name = "A glass of cherry slushy";
  8:   OBJ.aliases = {"cherry", "slushy", "glass"};
  9:   move(OBJ, player);
 10:   player:tell("You now have a cherry slushy.");
 11:   player.location:announce_all(player.name, " is served a cherry slushy.");
 12: elseif (dobjstr == "2")
 13:   player:tell("Please stand by for your drink to be blended.");
 14:   player.location:announce("A voice on the blender says, please stand by while your drink is being blended.");
 15:   suspend(15);
 16:   OBJ = create($drink, #-1);
 17:   OBJ.name = "A glass of grape slushy.";
 18:   OBJ.aliases = {"grape", "glass", "slush"};
 19:   move(OBJ, player);
 20:   player:tell("You now have a grape slushy.");
 21:   player.location:announce("Is served a grape slushy.");
 22: endif
 23: suspend(3);
 24: player.location:announce_all("A voice coming from the blender says, now shutting down.");
_25_ this.blending = 0;
now where would i put the statement like
if (thie.blending == 1)
player:tell("The blender is currently mixing a drink, please hold.")
" endif
 
not sure where i would put that or if that is the right code for it. slowly learning thanks and hpe that helps with me showing code.
 
 
\
Come join us on argon
107thezone.com
port 9350
Play a game with lots of fun.

Daniel Buczek

unread,
Dec 18, 2009, 7:48:37 PM12/18/09
to moo-...@googlegroups.com
Right at the start before you are creating any drinks. 

Remember: metacode is your friend. Don't know what metacode is? Instead of writing out code write out what you want to have happen. For example, 

If the blender is being used;
Being used message and quit;
Otherwise check for drink name;
Set blender to being used;
Blend appropriate drink;
Set blender to not being used;
End;

Generally you can keep expanding your metacode until each line represents an actual line of code (one thing in other words) and then just... Translate from English to whatever language you are working with.

--

You received this message because you are subscribed to the Google Groups "MOO Talk" group.
To post to this group, send email to MOO-...@googlegroups.com.
To unsubscribe from this group, send email to MOO-talk+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/MOO-talk?hl=en.

Tyler Littlefield

unread,
Dec 18, 2009, 7:40:03 PM12/18/09
to moo-...@googlegroups.com
John,
That's great improvement with showing the code. One thing though, is you might want to use $recycler:_create or set the owner to something with a quota.
Now, here's what I would do. Add your if statement at the very top, and after you use your player:tell message, use a return statement to halt the function then endif.
So:
if (this.blending)
player:tell("You can't use the blender while someone else is using it!")
return;
endif

Something you might want to note: You don't need ==1, just if(this.blending) anything other than 0 means true, so the if statement will do the same thing; it's just more elegant to use the statement like that.

Tyler Littlefield

unread,
Dec 18, 2009, 7:52:03 PM12/18/09
to moo-...@googlegroups.com
How is metacode going to answer his question? I think he wanted to find the equiv of the return statement. Metacode won't magically explain that.

johnny

unread,
Dec 18, 2009, 9:18:40 PM12/18/09
to moo-...@googlegroups.com
Thanks that makes sense.
Come join us on argon
107thezone.com
port 9350
Play a game with lots of fun.



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.427 / Virus Database: 270.14.114/2574 - Release Date: 12/18/09 19:38:00

Reply all
Reply to author
Forward
0 new messages