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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Sat Mar 07, 2009 5:54 pm   

Problem with expression.
 
Hi, I'm trying to make a trigger which will count how fast I'm making progresses on mud but I've met problem.

Poczyniles (.+) postepy, od momentu kiedy wszedles do gry\. <- You have made a (.+) progress since you logged in\.

#if (@postepy = %1) {
#if (@s_time) {} {s_time = %time(h)*3600+%time(n)*60+%time(s)}
} {
postepy = %1
e_time = %time(h)*3600+%time(n)*60+%time(s)
#if (@s_time) {} {s_time = @e_time}
}
Actually it is not problem with expression now as i've used originally wrong symbol to check if @postepy are exactly the same like %1 but a help with second problem will be appreciated.
Problem is with time - I don't know if there is in cmud any function what can give a difference between two dates/times so so far I'm changing time to amount of seconds but it will not work properly if start time will be near to midnight and end time will be after midnight. I would like to be able to get a amount of seconds since Epoch like in Unix System.


Last edited by Hemdall on Sat Mar 07, 2009 6:06 pm; edited 1 time in total
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Mar 07, 2009 5:59 pm   
 
Quote:
if @postepy and %1 are exactly the same


Code:
#if (@postepy == %1) {...
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Mar 07, 2009 6:11 pm   
 
Since it only applies while connected you could use the %ctime Predefined Variable. This will give the number of seconds you have been connected.

If you search around the forums you should also find a number of different posts that have solutions for doing time differences when dealing with full dates.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Tue Mar 17, 2009 10:43 am   
 
Using cMud I've encountered few problems and got few more questions too. Problems first:

1) I've noticed that sometimes when I jump to in to another window and then back to cmud and trying to type any command when I'm not in command line cMud is doing strange thing like walking or sending my last commands. It is thing I really don't appreciate as on my mud are location with traps so careless wandering around might end tragically and sometimes is hard to remember to click command line in.
2) I've got some problems with deleted by #unvar command variables and created again by script. For some reason cMud don't show that variable has changed, sometimes listing variable database type showing nothing despite there are some values. Variable in status bar don't update each time it has changed but only when a other variable in status bar changed too.
3) I've pulled main toolbar out and made it floating but now every time when I'm trying to start Editor prompt window with information about error in cMud.exe
Now turn for question:

Is it possible to add to key in database variable which not single word but sequence of words? I'm not sure if my question is enough precise so I'll show on example:

I want to create in database particular pair:

Muscular merry dwarf Drakan
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Mar 17, 2009 11:14 am   
 
About your fourth question: yes, use %db(@var,"key") instead of @var.key.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Tue Mar 17, 2009 1:29 pm   
 
Ok, I've written my script but I met another problem. I've taken description from database and put it in string list variable. After that I've created trigger with this variable in pattern. Everything was fine until I've removed a this new variable. There was still a trigger but not variable so I suppose that is a reason that program stop responding. My question is what i should do to avoid it? I mean I would like trigger to check if this particular variable exists and do nothing if not.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 17, 2009 1:36 pm   
 
My first question is, why are you deleting and recreating the variable? Is there a particular reason for this? Why not just set the variable to %null instead? Creating and destroying variables takes a lot more processing time than simply setting a value.

If you can explain what you are trying to do, perhaps I can help further.
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Tue Mar 17, 2009 1:58 pm   
 
I intend to create script which will add all introduced to me people to database and will substitute their description with description + (name). To do that i need a create variable with all descriptions from my database and put that variable into pattern. I want avoid situation when in variable will be any mess - I mean something what i added wrong or description persons what i could have deleted so every time before i loop through database i declare that variable is null
pattern_of_trigger = "" I think that is a reason that cMud stop responding because if that variable is empty the pattern in trigger is empty too. I wan't avoid situation when let say by accident or someone not aware will delete that variable and my/his program will stop working - it might be a bit risky.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 17, 2009 2:26 pm   
 
Does the information have to be in the database? Have you considered a database variable instead? How often are you recreating this variable list? Creating the string list each time will take quite a bit of processing (perhaps thats why cmud stops responding?). Using a database variable might be a better solution. You can directly use the database variable in your trigger--it will be interpreted as a string list of the keys. You won't have problems of the list getting out of sync with your database.
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Tue Mar 17, 2009 2:42 pm   
 
Actually it is database variable. String list variable is recreated manually - i'm using alias to initialize it. Do you mean trigger should work just with (@dbchar) in pattern?

I checked it and now it works perfectly - thanks for help.
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Sat Oct 03, 2009 2:45 pm   
 
Another problem:
I've created trigger which catch under %1 hit location and under %2 description of armor which protected me against that hit.
%1 head
%2 golden red-winged helmet
#switch (%1=="head") {
$t = %replace(%2," ","_")
hits_head = @hits_head + 1
The problem starts when i try to create variable where a part of name is $t:
hits_head_protected_by_$t = @hits_head_protected_by_$t + 1
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Oct 05, 2009 1:25 am   
 
I haven't tested this, but try:
Quote:
#var hits_head_protected_by_$t (@hits_head_protected_by_$t + 1)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Oct 05, 2009 1:35 am   
 
Sorry, just tested it. Do this:
Quote:

$varname = %concat("hits_head_protected_by_",$t)
#var %eval($varname) (@{$varname) + 1)
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Fri Oct 16, 2009 3:47 pm   
 
Is there possibility to check a width of my output window and if answer is yes how could i do that?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 16, 2009 4:06 pm   
 
There isn't any way to determine the width of your output window from a scripts.

Also, in the future, please create a NEW topic for new questions rather than resurrecting old topics like this. Thanks.
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Sat Oct 17, 2009 1:19 am   
 
Thanks for reply Zugg. If you insist or you like i'll create new topic for every question i have but i find it much easier to ask in this topic as i don't have to search for all my posts and i can with easy go back to replies and suggestions people has given me regarding my problems.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Oct 17, 2009 4:46 pm   
 
The problem is that the Gurus and other people helping on this forum answer posts based upon the Topic Title, so if you ask a question within an old topic like this, fewer people will read it, and therefore you'll get less help.

When you are logged in to this site, if you go to the www.zuggsoft.com Home page, you will see links near the bottom of the left column for "Show topics that I started" and "Show all of my posts" that you can use to monitor your various threads. You can also click the option at the bottom of an individual topic called "Notify me when a reply is posted" to get email notification when someone updates your thread.

So Yes, you should definitely create a new topic for each question that you have.
Reply with quote
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Sat Oct 17, 2009 6:22 pm   
 
Zugg: I know this options but for various reasons I do not want to use them (f.e i don't want spam in my mailbox everytime someone will reply in watched topics - I prefer to check it for every now and then directly on the forum and i prefer don't search for anything if i could had all in one topic) but i understand that Topic Title might be a hint for what the problem is about so from now I'll start new topics given i'll have further questions.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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