Welcome to the Builder Academy

Question dg_script question

More
13 Jul 2012 16:17 - 13 Jul 2012 16:18 #355 by bakarus
dg_script question was created by bakarus
I'm attempting to create a script for an item in my mud, it will act like a two-way portal, like this:

Tom drops a gateway on the ground.

Tom types "enter gateway" and is transported to a specified location.

Tom types "leave gateway" and is transported back to the spot where the gateway currently is.

Being dropped on the ground has the potential hazard of mobs or other players picking it up.

I have this for a start:

Code:

if %cmd.mudcommand% == enter && gateway /= %arg%
%send% %actor% You step into the gateway.
%echoaround% %actor% %actor.name% steps into the gateway.
%teleport% %actor% 7798
%force% %actor% look
%echoaround% %actor% %actor.name% just stepped through a gateway.
else
%send% %actor% enter what?!
end


Now the exit part is tough, the player wont' have the gateway so I think it would have to be a room script in the location the gateway takes you to, I'm not sure how to tell what room the gateway is currently in to %teleport% the player back to.

Any help with this will be very much appreciated.
Last edit: 13 Jul 2012 16:18 by bakarus.

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

More
13 Jul 2012 17:22 #356 by Papaya Pete
Replied by Papaya Pete on topic Re: dg_script question
Wow that's a good one! Hmmm. What have you tried so far? Have you tried just teleporting to the name of the object? I was looking over the variables section of the DG script help section, might try using these...

%findobj.<room vnum>(<obj vnum>)%
%findobj.<room vnum>(<obj variable>)%
%findobj.<room vnum>(<name>)%

Though one problem would be that it's checking a specific vnum.

Anyways, here's a link to where the help section is at. I'm guessing that this is something that Rumble would be able to figure out.
Code:
http://www.tbamud.com/Oasis_DG_pages/contents/variables.htm

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

More
13 Jul 2012 19:52 #357 by Rumble
Replied by Rumble on topic Re: dg_script question
Probably the simplest solution would be to create a return portal object and trigger then add the below to your original trigger:
Code:
%at% 7798 %load% obj <return portal vnum>
Let me know if you have other questions and if this works for you.

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com

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

More
13 Jul 2012 20:17 - 13 Jul 2012 20:28 #360 by bakarus
Replied by bakarus on topic Re: dg_script question
I decided to just have it stay in the players inventory, and the below code now works.
Code:
if %cmd.mudcommand% == enter && %arg% /= gateway %send% %actor% You enter the gateway. %echoaround% %actor% %actor.name% bravely enters the gateway. %teleport% %actor% 7798 %force% %actor% look %echoaround% %actor% %actor.name% just stepped through the gateway. else %send% %actor% %cmd% what?! end

Now that the character has been transferred to a new room, I need to be able to send them back to the room they came from, so if the player started in room 3000 and used 'enter gateway' they are now in room 7798, I need to make it so when they type 'exit gateway' it takes them back to room 3000, or whatever room they were initially in.

Maybe I could add a Global variable in the first script like:
Code:
global original_vnum = %self.vnum()% if %cmd.mudcommand% == enter && %arg% /= gateway %send% %actor% You enter the gateway. %echoaround% %actor% %actor.name% bravely enters the gateway. %teleport% %actor% 7798 %force% %actor% look %echoaround% %actor% %actor.name% just stepped through the gateway. else %send% %actor% %cmd% what?! end

Then from a 2nd script on the object, use that global like:
Code:
if %cmd.mudcommand% == exit && %arg% /= gateway %send% %actor% You enter the gateway. %echoaround% %actor% %actor.name% bravely enters the gateway. %teleport% %actor% original_vnum %force% %actor% look %echoaround% %actor% %actor.name% just stepped through the gateway. else %send% %actor% %cmd% what?! end
Last edit: 13 Jul 2012 20:28 by bakarus.

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

More
13 Jul 2012 21:11 #361 by bakarus
Replied by bakarus on topic Re: dg_script question
I currently have this as my initial script:
Code:
Name: 'Gateway trigger', VNum: [ 7700], RNum: [ 869] Trigger Intended Assignment: Objects Trigger Type: Command , Numeric Arg: 7, Arg list: enter Commands: set original_vnum = %actor.vnum% global original_vnum if %actor.vnum% != 7798 if %cmd.mudcommand% == enter && %arg% /= gateway %send% %actor% You enter the gateway. %echoaround% %actor% %actor.name% bravely enters the gateway. %teleport% %actor% 7798 %force% %actor% look %echoaround% %actor% %actor.name% just stepped through the gateway. else %send% %actor% %cmd% what?! end else %send% %actor% you are already here! end

It sends the player to vnum 7798, then the next script:
Code:
Name: 'Gateway return', VNum: [ 7701], RNum: [ 870] Trigger Intended Assignment: Objects Trigger Type: Command Get , Numeric Arg: 7, Arg list: leave Commands: if %cmd.mudcommand% == leave && %arg% /= gateway %send% %actor% You enter the gateway. %echoaround% %actor% %actor.name% bravely enters the gateway. %teleport% %actor% original_vnum %force% %actor% look %echoaround% %actor% %actor.name% just stepped through the gateway. else %send% %actor% %cmd% what?! end

The second script always sends the player to vnum 800, not sure what i'm doing wrong here, and no the player isn't at vnum 800 originally.

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

More
13 Jul 2012 21:14 #362 by Rumble
Replied by Rumble on topic Re: dg_script question
In that case, I would make one "enter" trigger and if actor.vnum = 7798 teleport to the other room and remote the global variable. If not 7798 teleport to 7798.

There are always several ways to do any trigger. KISS method is usually the best approach.

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com

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

Time to create page: 0.202 seconds