Welcome to the Builder Academy

Question Issue with variables

More
31 Jul 2012 21:45 - 01 Aug 2012 00:22 #492 by Papaya Pete
I can't seem to figure out how to make set and eval work, and it's getting a little frustrating. What is it that I'm doing wrong? This is a room trigger designed to make it so the player can't dig in the same spot over and over again. it works, except for the fact a player can dig repeatedly.
Code:
if !%actor.has_item(1047)% %send% %actor% You can't dig, you don't have a shovel! else if %actor.varexists(has_dug_1091)% %send% %actor% You've dug around here before, there's nothing else you can find. else context %actor.id% set has_dug_1091 1 global has_dug_1091 %send% %actor% You begin to dig around the mounds, searching for anything useful. Hmmm, bones, dirt, more bones and dirt... %echoaround% %actor% Ewww! %actor.name% starts digging into the mounds of dirt, uncovering some bones and such! What is %actor.heshe% looking for...? wait 10 %send% %actor% You uncover an old scroll case! You peek inside and there isn't anything in it, but it's still useful! %echoaround% %actor% %actor.name% uncovers an old scroll case! %actor.heshe% peeks inside and stashes it in %actor.hisher% inventory. %load% obj 1046 %actor% inv end end
Last edit: 01 Aug 2012 00:22 by Rumble.

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

More
01 Aug 2012 00:19 - 01 Aug 2012 00:20 #495 by Rumble
Replied by Rumble on topic Re: Issue with variables
I think all you need to do is change the variable check to:
if %has_dug_1091%

varexists is used to check remote variables that are written to a pfile. Global variables are fine if you don't care about losing them over reboot/copyover.

But just in case here is an example:
Code:
Name: 'Lieutenant Door Bribe - M23608', VNum: [23612], RNum: [ 2657] Trigger Intended Assignment: Mobiles Trigger Type: Bribe , Numeric Arg: 1, Arg list: None Commands: * By Welcor of The Builder Academy tbamud.com 9091 wait 1 * The price is 400 coins to pass. Player must 'give 400 coin leader.' if %amount% < 400 say Did you really think I was that cheap, %actor.name%. snarl else * Context saves the global with the players ID so multiple players can bribe. context %actor.id% * Set the variable to a value, 1 for YES. set has_bribed_guard 1 * Global it! You can now 'stat leader' and see it listed. global has_bribed_guard whisper %actor.name% Enter when you're ready. I'll lock the door behind you. unlock door end > tstat 23613 Name: 'Lieutenant Door Bribe 2 - M23608', VNum: [23613], RNum: [ 2658] Trigger Intended Assignment: Mobiles Trigger Type: Door , Numeric Arg: 100, Arg list: None Commands: * By Welcor of The Builder Academy tbamud.com 9091 * Allows more than one instance of this trigger to run. context %actor.id% * Checks a global variable to see if this mob has been bribed. TSTAT 23612. if %has_bribed_guard% * Let the player through, he's paid. return 1 * Don't bother continuing the trig, just stop it. halt end * If the player tries to pick the lock catch him! if %cmd% == pick * Stop them! Return 0 prevents the command from going through. return 0 wait 1 say No way, you don't fool me, %actor.name%. * If mob can see the player, kill him! if %actor.canbeseen% mkill %actor% end end

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com
Last edit: 01 Aug 2012 00:20 by Rumble.

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

More
01 Aug 2012 01:35 #497 by Papaya Pete
So I tried that, but it's still not working properly. I would like for it to be a one-time thing, since people can take advantage of it otherwise, but eh.
Code:
) Name : Digging Up Mounds in 1093 2) Intended for : Rooms 3) Trigger types: Command 4) Numeric Arg : 100 5) Arguments : dig 6) Commands: if !%actor.has_item(1047)% %send% %actor% You can't dig, you don't have a shovel! else if %has_dug_1091% %send% %actor% You've dug around here before, there's nothing else you can find. else context %actor.id% set has_dug_1091 1 global has_dug_1091 %send% %actor% You begin to dig around the mounds, searching for anything useful. Hmmm, bones, dirt, more bones and dirt... %echoaround% %actor% Ewww! %actor.name% starts digging into the mounds of dirt, uncovering some bones and such! What is %actor.heshe% looking for...? wait 10 %send% %actor% You uncover an old scroll case! You peek inside and there isn't anything in it, but it's still useful! %echoaround% %actor% %actor.name% uncovers an old scroll case! %actor.heshe% peeks inside and stashes it in %actor.hisher% inventory. %load% obj 1046 %actor% inv end end

It just seems like it's not setting the variable at all. This is pretty frustrating, when it seems like something should work just fine but for an unknown reason it isn't. Or maybe it's just me...

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

More
01 Aug 2012 01:48 #498 by Rumble
Replied by Rumble on topic Re: Issue with variables
Stat the player, to see if the global variable is there. You could also try remoting. I'll test it out on TBA.

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

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

More
01 Aug 2012 02:04 #500 by Papaya Pete
Ok, I'll try remoting it unless that's something you've already tried as well. Will let you know how it goes.

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

More
01 Aug 2012 02:09 #501 by Vatiken
Replied by Vatiken on topic Re: Issue with variables
Global variables attached to a mobile/room/object can be "contexted" so that they can be set/unset for individual players. An example of use might be a bonus for finding a certain room, as in you'd like it to reward every player who found the room, but only once per player.

If you do a stat on the mobile/room/object you will see all global variables connected to it, aswell as which context (typically set by a player's ID number).

Your example isn't working because you are setting the mobile's global context to the actor's idnum AFTER you check for it.
Code:
... if %has_dug_1091% %send% %actor% You've dug around here before, there's nothing else you can find. else context %actor.id% set has_dug_1091 1 ...
Should be...
Code:
... context %actor.id% if %has_dug_1091% %send% %actor% You've dug around here before, there's nothing else you can find. else set has_dug_1091 1 ...

tbaMUD developer/programmer

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

Time to create page: 0.214 seconds