Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Leopardfist
Beginner


Joined: 19 Nov 2012
Posts: 10

PostPosted: Mon Nov 19, 2012 8:49 pm   

Help writing to a DB using Trigger
 
I am trying something that seems simple, but it will not work. First I will show the output that I get when I want my trigger to fire, which it does fire. I just cannot get the variable thing to work.

MUD OUTPUT I NEED FOR TRIGGER:
This ranks you as Davin of Shienar (Level 3).
Your base abilities are: Str:16 Int:15 Wil:12 Dex:18 Con:13.

My Class I started to practice:
Code:

#CLASS {StatTracker}
#ALIAS Showstats {#ECHO &Name -- with stats Str:&STR, Int:&Int, Wil:&Wil, Dex:&Dex, Con:&Con}
#VAR Name {}
#VAR Str {}
#VAR Int {}
#VAR Wil {}
#VAR Dex {}
#VAR Con {}
#TRIGGER {This ranks you as * of *} {#VAR Name %1}
#TRIGGER {Your base abilities are: Str:&Str Int:&Int Wil:&Wil Dex:&Dex Con:&Con *} {}
#CLASS 0


Now I get the trigger to fire, but when I do "Showstats" to test wether the Name was captured into the variable it doesnt show the name. Also as you can see I have tried several different ways of getting the variables, which I learned from the examples in the documentation for triggers.

Also, the entire reason I am starting this is the MUD I play you have to level to 3 to see the stats you got, and if you dont like them to then restat and start again at 1. I want to make a Class that will store the stats in a database everytime I restat, storing the old stats. And I want to be able to use a command like Stattrackerlist to show all the stats I went thru for the character, how many times I had to restat, and also show the stat totals like Strength + Intelligence + Willpower + Dexterity + Constitution.

So if anyone knows what they are doing, and can make this in a simple way for me, that would not be a terrible thing hehe. I do not mind learning, it just seems like I am having a problem with the learning part lol.

OH and one more thing, I saw a page last week that was Fun with Triggers, which many more examples than the documentation, however I cannot find the link anymore, anyone know where it is?

Thanks for any advice or assistance :)!

BTW The game is Wheel of Time MUD :).


Last edited by Leopardfist on Tue Nov 20, 2012 12:08 am; edited 1 time in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Mon Nov 19, 2012 9:12 pm   
 
you need to use @varname when referancing variables, &varname only works for in pattern variable defining
_________________
Discord: Shalimarwildcat
Reply with quote
Leopardfist
Beginner


Joined: 19 Nov 2012
Posts: 10

PostPosted: Mon Nov 19, 2012 9:28 pm   
 
Awesome! THANK YOU! It workes perfect now hehe. Now I have to learn database to store the dang things :).
Reply with quote
Leopardfist
Beginner


Joined: 19 Nov 2012
Posts: 10

PostPosted: Mon Nov 19, 2012 11:22 pm   
 
OK, now I have another problem. I got my script to record the name, and the stats in the variables and to echo them. I have another variable that is the total of all 5 stats. I got all of that working, and then I went to work trying to use a Database to record said values, and well I cant seem to get the values to record using the #NEW for new record command.

I have my database made, it is very basic with only 7 fields which are below.

Name Total Str Int Wil Dex Con

My Script follows:
Code:

#CLASS {StatTracker}
#ALIAS Showstats {#ECHO @Name -- with stats Str:@Str, Int:@Int, Wil:@Wil, Dex:@Dex, Con:@Con Total:@Tot}
#VAR Name {}
#VAR Str {}
#VAR Int {}
#VAR Wil {}
#VAR Dex {}
#VAR Con {}
#VAR Tot {}
#TRIGGER {This ranks you as &Name of *} {}
#TRIGGER {Your base abilities are: Str:(%d) Int:(%d) Wil:(%d) Dex:(%d) Con:(%d).} {
  #VAR Str %1
  #VAR Int %2
  #VAR Wil %3
  #VAR Dex %4
  #VAR Con %5
  #MATH Tot %1+%2+%3+%4+%5
  }
#TRIGGER {You feel dizzy as time seems to spin backwards...} {#New St Name %Name Str %1 Int %2 Wil %3 Dex %4 Con %5 Total %Tot}
#CLASS 0


That was my last try.... I also tried it with the {#New St {Name=%Name|Str=%Str| Etc etc etc.

Couldnt get it to work in any of the ways shown on the #New directions of the documentation.

Thanks for the continued help.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Nov 19, 2012 11:22 pm   
 
If you want @name to update, you need to use () around the wildcard pattern you want assigned to %1.
_________________
EDIT: I didn't like my old signature
Reply with quote
Leopardfist
Beginner


Joined: 19 Nov 2012
Posts: 10

PostPosted: Mon Nov 19, 2012 11:35 pm   
 
I'm not sure I follow, I have the name variable working, it's the trigger to write the data to the database that isn't working. It triggers fine, I tested the trigger part, but my commands to add the new record to the database is not working.

This Line:
Code:

#TRIGGER {You feel dizzy as time seems to spin backwards...} {#New St Name %Name Str %1 Int %2 Wil %3 Dex %4 Con %5 Total %Tot}
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Mon Nov 19, 2012 11:51 pm   
 
Looking at the helpfile
#NEW st Name=%name Str=%1 etc=etc

is better syntax... but really, CMUD handles dbvariables much better than zMUD
_________________
Discord: Shalimarwildcat
Reply with quote
Leopardfist
Beginner


Joined: 19 Nov 2012
Posts: 10

PostPosted: Tue Nov 20, 2012 12:02 am   
 
OK, Tried that still not working hehe. Have tried the following lines all did not work.

Code:

#TRIGGER {You feel dizzy as time seems to spin backwards...} {#New St {Name=%Name|Str=%Str|Int=%Int|Wil=%Wil|Dex=%Dex|Con=%Con|Total=%Tot}}

Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Tue Nov 20, 2012 1:36 am   
 
have you got your database #DBLOAD ed? I believe that is required.

and %str is likely not going to return anything, it may well be taken for a literal string, also %name (like %str) is not an internal function... %char should be what holds your character's name
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net