Welcome to the Builder Academy

Question A scripting question - Justice

More
20 Sep 2012 14:52 #813 by Papaya Pete
So it's been a while, I took a hiatus from working on my mud for a few months. This time, I'm trying to build a bit differently; writing it all down and plotting it out instead of trying to come up with things as I work.

Here's an interesting justice system I had in mind.

I was going to have the game keep track of how many offenses were made. The more offenses (theft, attacking an npc, and so on), the longer the player would have to sit in prison.

Now the question I have is regarding this part: every day, at a set time (12pm) I was going to have the jailer come into the prison cell with all the prisoners, check every player that's in there, and reduce a variable that has been tagged on them (prison_term I will call it) by one. If, after reducing it by 1, prison_term is equal to zero... the player is released from prison. If not, he sits in there. All that, I know how to do.

How do I have this check run on multiple players in the room? How can the mob tell if there is two, three, or more and run it successfully?

Please Log in or Create an account to join the conversation.

More
20 Sep 2012 23:35 #815 by Vatiken
Code:
eval room %self.room% eval target %room.people% while %target% if %target.is_pc% && %target.varexists(jailer_variable)% DO STUFF end eval target %target.next_in_room% done
Something like that???

tbaMUD developer/programmer

Please Log in or Create an account to join the conversation.

More
21 Sep 2012 17:09 #817 by Papaya Pete
Yeah, something like that! I always had issues with eval and remote, I'll have to do read up on them and do some practice to brush up on it again.

The idea behind this is the more the player tries causing trouble in town (and gets caught), the longer he ends up sitting in jail. I've been on other muds where there are players who just try to kill any mob, even when it's something that isn't meant to be killed (shopkeeper, a coach driver, and so on). I figure something like this might curb it and make things a little interesting as well.

Please Log in or Create an account to join the conversation.

More
23 Sep 2012 17:08 #820 by Fizban

Papaya Pete wrote: Yeah, something like that! I always had issues with eval and remote, I'll have to do read up on them and do some practice to brush up on it again.


You can, and in fact should, use set instead of eval in all instances in the above script.

Please Log in or Create an account to join the conversation.

More
26 Sep 2012 00:55 - 26 Sep 2012 01:04 #824 by Vatiken

The set command is used to set (or create) the specified variable equal to the provided expression, which will be evaluated when the variable is accessed.

Right you are... I forgot that the variable will be evaluated when accessed. I always made the assumption that set does NOT evaluate while eval DOES...

I think we had this convo before...


..........

Is eval superior in this case anyway as the variable will need to be evaluated once anyway? Without looking at the code, I can't imagine there would be much difference in my example above if the variable is evaluated when created or evaluated when used.

tbaMUD developer/programmer
Last edit: 26 Sep 2012 01:04 by Vatiken.

Please Log in or Create an account to join the conversation.

Time to create page: 0.174 seconds