Author Topic: Script Help, please.  (Read 14777 times)

0 Members and 1 Guest are viewing this topic.

Offline Tocharaeh

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
    • 4Dimensions on Facebook!
Script Help, please.
« on: August 21, 2010, 01:49:55 am »
I'd like to put in my smaller zone asap. I'm a scripting dunce when it comes to things that are complicated. The only reason my zones aren't pouring into 4D GP is because I can't script past very simple things.

Anywho. This is what I need.

I need a special lever script that will do the following:

Player 1 pulls LeverA, script will prompt the player now and then to ensure that they continue to hold down on the Lever. Main door script will acknowledge that requirement 1 has been met (until the player looses grip, or lets go).

Player 2 will pull LeverB, and hold. Main door script will acknowledge that requirement 2 has been met.

Player 3 will pull LeverC, and hold. Main door will open. Player 1 will now be able to release his/her lever, and cross into the next room, and pull a switch that will LOCK the door in place, thus allowing the other two players to also release their levers without risk of the door closing.

There is no order to the levers as long as all three are pulled, and held so that player 1 can lock the door in place.

Door can be opened from the other side should it close, so that players can try again should one accidentally release the lever before the switch is thrown. Door will of course be closed and locked until they restart and complete the process.

Could someone PLEASE OH PLEASE with smaller PRETTY PLEASE sprinkles on top help me with this? LH was supposed to a long time ago, and abandoned me, and I most certainly cannot script such a thing.
-Tocharaeh D'Araesth
The Dirty Ol'' Drow that time left behind in fear of obliteration!

Offline Prometheus

  • the bang your head against the wall coder.
  • Administrator
  • Sr. Member
  • *****
  • Posts: 365
    • View Profile
Re: Script Help, please.
« Reply #1 on: August 23, 2010, 12:20:30 pm »
I would say yuor best bet would be to talk to Thotter or Fizban since they are out resident script gods :)

Prometheus

Offline Tocharaeh

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
    • 4Dimensions on Facebook!
Re: Script Help, please.
« Reply #2 on: August 23, 2010, 11:53:19 pm »
Dang. Both of them have abandoned me completely in the past too. This is why I don't have zones published.
-Tocharaeh D'Araesth
The Dirty Ol'' Drow that time left behind in fear of obliteration!

Offline Molly

  • Administrator
  • Hero Member
  • *****
  • Posts: 691
    • View Profile
Re: Script Help, please.
« Reply #3 on: August 24, 2010, 04:31:16 pm »
One thing that I don't quite understand with your setup is how the script would know if a player released the lever. There is no command to actively 'release'. 'lose grip' or 'let go of' something like a lever, so I doubt any player would type in such a command, they'd just leave, when they tired of it. Consequently the only thing I can think of is to check if all three players are still present in the room when the last lever is pulled.

One way to check this would be to make a  separate LEAVE trigger to unset the global flag if they leave the room in any way. There is probably a more elegant way to check if a certain player is in the room, but I cannot find any in the files right now. Maybe one of the script experts can help with that part?

Anyhow, for the main door script work you need to make two checks; A. if all three players each pulled a lever and B. if all three of them are still in the room. Something like the script below: (substitute PlayerA etc. for the real names of the players)

eval player_name %actor.name%
if %actor.name% == <PlayerA>
  if !PlayerA
   eval PlayerA 1
   global PlayerA
   %send% %actor% You grab a lever and hold it.
   %echoaround% %actor% %actor.name% grabs a lever and holds it.
  else
   %send% %actor% You are already holding a lever, that's all you can handle.
  end
elseif %actor.name% == <PlayerB>
  if !PlayerB
   eval PlayerB 1
   global PlayerB
   %send% %actor% You grab a lever and hold it.
   %echoaround% %actor% %actor.name% grabs a lever and holds it.
  else
   %send% %actor% You are already holding a lever, that's all you can handle.
  end
elseif %actor.name% == <PlayerC>
  if !PlayerC
   eval PlayerC 1
   global PlayerC
   %send% %actor% You grab a lever and hold it.
   %echoaround% %actor% %actor.name% grabs a lever and holds it.
  else
   %send% %actor% You are already holding a lever, that's all you can handle.
  end
endif
wait 3 s
if (%PlayerA% == 1) && (%PlayerB% == 1) && (%PlayerC% == 1)
 %door% 7551 west flags a
 %echo% The door silently slides open.
 %send% PlayerA Great! Your buddies are holding the door open so you can let go of your lever.
 %send% PlayerA Now you can go to the next room to lock the door in an open position.
endif


It's not much more than a first outline, and I'm not sure about the first line. In any case what you want is rather complex, you'll need separate scripts for locking the door, and for checking that all players remain in the room until the door is open. But I really haven't got the time for scripting right now, since the kids are still out of daycare. I'll hopefully have more time for the mud again in a month, when we get back from our trip to Italy.

It would be nice to finally see your zone in the Gameport, but getting Diandra, Thotter or Fizban to help would probably be quicker than waiting me out.


Offline Diandra

  • Administrator
  • Full Member
  • *****
  • Posts: 143
    • View Profile
    • Email
Re: Script Help, please.
« Reply #4 on: August 27, 2010, 03:26:26 am »
I'd prefer to finish updating a zone I haven't worked on for over a year before I throw myself on other projects again, otherwise the update will never finish. So I'm sorry Toch but this will have to wait a bit if you want me to look at this. And even then it's no promess, as Molly already said it's a complex thing, but what she posted here is already a start. Of course it doesn't help that certain situations in RL are taking all my energy either...

Offline Kvetch

  • Administrator
  • Hero Member
  • *****
  • Posts: 729
    • View Profile
    • Email
Re: Script Help, please.
« Reply #5 on: September 03, 2010, 10:44:53 pm »
Have posted this on CWG Project Home and hope we'll get a response there.  I think it's an interesting idea and we'll see what they come up with - provided they look at their webpage frequently.  It seems the Trigger of the day was dropped a bit ago (cries).  I think this is an interesting concept and would be able to be adapted to other things easily.

Offline Kvetch

  • Administrator
  • Hero Member
  • *****
  • Posts: 729
    • View Profile
    • Email
Re: Script Help, please.
« Reply #6 on: September 04, 2010, 09:48:41 pm »
Jamdog from TBA and his own mud posted on CWG and asked these questions.  I did answer them the best I thought of, but I thought Tochy would have more insight since it is his script.  Jamdog does ask if it had to be script only or if a combination of the two would work.  Prom happened to be on and I mentioned it would mean he'd have to get involved and he said he'd try, so, if Jamdog (or anyone else there) doesn't come up with a script only solution, we could try a combination.  Here is Jamdog's post:

A couple of questions about this...

Does it have to be scripts only, or will a script/spec-proc combination do?

What happens when the zone resets? Do the 'locked' levers unlock themselves, and return to their normal position?

What command is used? The 'pull' command doesn't normally mean you hold a lever - would it make sense if 'pull lever' returned "You pull the lever, but it returns to the upright position", and 'hold lever' returns "You pull and hold the lever"

If you are holding the lever, do you need to 'release' it, or can you just walk away to release it?

When all three levers are held, can any of the three players release a lever, and move to the next room, or does it just have to be 'player 1'.

What do players type to pull the 2nd lever? Will the 'pull/hold lever' command pull the next unpulled lever, or does the player need to 'pull/hold lever n'?

Personally, I'd make each lever an obj spec-proc, and have a static or global array of char_data structs, with info on who is holding the levers (so when they are locked, it's easier to send a message to them, like "You hear a click as the lever is locked into position", and they would be NULL if no-one is holding the lever). The spec-proc could handle the pull/hold/release commands as well as attempts to leave. It could also set/unset an obj var (if the lever is type OTHER, then v0 is free), which scripts could then use to check if a lever is held.

I can throw together a lever spec-proc for you, and you can see how it compares to a scripted version, if you like.


My reply to Jamdog's post was this:

I'd love for it to be script only. We do have some good coders, but our most active coder is still learning and is already having some problems with other processes that we're trying to install. He does say that if it comes down to it, he will try to help if it needs to be a script/spec process combination. Now, on to the answers to your questions. Please note, these are the answers I *think* the builder wants, but will not be 100% sure on that until he answers a copy of your post that I'll leave on our website.

Zone reset: I would think that the levers would return to their normal positions.

Releasing levers: I would think that just walking away would release it - which I believe is what he was looking for.

Re-reading the post, I believe whichever player was the first player to pull a lever (no matter which lever was pulled first) is the one that is able to move to the next room to lock the levers in place.

I believe that he wants it so the player actually has to choose which lever to pull... so pull lever 2, or pull lever 1 (or lever red and lever orange), but as stated, it doesn't matter which order they're pulled in, just that all 3 get pulled. But for later building, I wouldn't mind something that could be adapted so it may require a specific order in which to be pulled. But that could be a whole 'nother animal.

On that note too of this being adapted for another script, I seem to remember rumbling about having the same basic thing, but in seperate rooms (lever 1 is in room a and lever 2 is in room b, etc). Would that be easier or harder to do?

As I said though, our most active coder is willing to give a spec-proc a try if it is needed to do this. Thank you for all of your time and energy Jamdog! I would like to see what you can come up with.

Offline Fizban

  • Maniacal Scroder!
  • Administrator
  • Full Member
  • *****
  • Posts: 183
  • Fizban, the Mangy Wizard
    • MSN Messenger - Fizban1216@hotmail.com
    • AOL Instant Messenger - Fizban1216
    • View Profile
    • Email
Re: Script Help, please.
« Reply #7 on: September 05, 2010, 02:52:46 pm »
Player 1 pulls LeverA

Easy enough.

script will prompt the player now and then to ensure that they continue to hold down on the Lever.

How should this work exactly? (I don't mean in terms of script syntax, just what it should be checking to determine whether or not they are still holding it.)

There is no order to the levers as long as all three are pulled, and held so that player 1 can lock the door in place.

Should it simply require that two of the three levers are continually held, or should it specifically check that the lever is released is the one that was first pulled?