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 Goto page Previous  1, 2, 3
Xerakon Posted: Mon Jul 09, 2012 10:54 pm
GUI
shalimar
GURU


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

PostPosted: Sun Aug 12, 2012 4:14 pm   
 
Alias name should only be one word.
_________________
Discord: Shalimarwildcat
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sun Aug 12, 2012 5:47 pm   
 
Can it be made into two, or is that a strict no-go?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Aug 12, 2012 6:58 pm   
 
An alias cannot be multiple words, so you can't have an alias "xconfig testclass". Instead, I suggest making the alias be "xconfig", with two parameters, one for the name of the class, and the other the on/off. You might also do a single #IF statement with an Else clause, instead of two #IF statements. Like so:
Code:

<alias name="xconfig" id="1">
  <value>#IF (%2 = on) {#T+ %1} {#T- %1}</value>
</alias>


[edit]
If you want this to only work on a specific set of classes, then make a list of the classes you want the command to work on and test whether the first parameter is one of them:
Code:

<alias name="xconfig" id="1">
  <value>$classes = {testclass|otherclass|yetanotherclass}
#IF (!%ismember(%1, $classes)) {#EXIT}
#IF (%2 = on) {#T+ %1} {#T- %1}</value>
</alias>
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Aug 12, 2012 7:23 pm   
 
You could use a command input trigger to have a two word "alias", but Rahab's code is more flexible.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sun Aug 12, 2012 11:30 pm   
 
Code:

// This function fills the status window. If you need to manually refresh it, use the VREPORT command.

// Clears the Status window to receive the new information.
#CLR Status

// Line 1: Displays Hitroll, Damroll, Strength, Dexterity, Constitution, Intelligence, Wisdom, and Charisma. The major stats will be in a nn (nn) format. The left set are your stats after all modifiers. Inside parenthesis are permanent stats, which are affected only by training and cybernetics.
$line1 =  %format("<color red>HIT: <color lightgrey>&s</color>     <color red>DAM:</color> <color lightgrey>&s</color>     <color red>STR:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>     <color red>DEX:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>     <color red>CON:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>     <color red>INT:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>     <color red>WIS:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>     <color red>CHA:</color> <color lightgrey>&s</color> <color red>(</color><color lightgrey>&s</color><color red>)</color>", @HITROLL, @DAMROLL, @STR, @STRPERM, @DEX, @DEXPERM, @CON, @CONPERM, @INT, @INTPERM, @WIS, @WISPERM, @CHA, @CHAPERM)

// Line 2: Total, Inventory, and Bank Credits. Comlink Frequency and Encryption.
$line2 = %format("<color red>Total Credits:</color> <color lightgrey>&s</color>     <color red>Inventory:</color> <color lightgrey>&s</color>     <color red>Bank:</color> <color lightgrey>&s</color>                       <color red>Frequency:</color> <color lightgrey>&s</color>     <color red>Encryption:</color> <color lightgrey>&s</color>", @MONEYTOTAL, @MONEYINV, @MONEYBANK, @COMMCHANNEL, @COMMENCRYPT)

// Line 3: Reserved for cargo plugin I'm working on.
$line3 = %format("<color red>Reserved for cargo plugin.</color>")

// Line 4: Reserved for botting plugin I'm working on.
$line4 = %format("<color red>Reserved for botting plugin.</color>")
//$line4 = %format("&d:&02d:&02d", (@BotTime / 3600), %mod(@BotTime / 60, 60), %mod(@BotTime, 60))

// Line 5: Reserved.
$line5 = %format("<color red>Reserved.</color>")

// Line 6: Sublight information. Star System, Star Coordinates, Current XYZ, Coursing XYZ.
$line6 = %format("<color red>Star System:</color> <color lightgrey>%s</color>   <color red>Coordinates:</color> <color lightgrey>%s %s</color>     <color red>Current Position:</color> <color lightgrey>%s %s %s</color>     <color red>Heading:</color> <color lightgrey>%s %s %s</color>", @SHIPSYSNAME, @SHIPGALX, @SHIPGALY, @SHIPSYSX, @SHIPSYSY, @SHIPSYSZ, @SHIPHEADX, @SHIPHEADY, @SHIPHEADZ)

// Adds the lines to the window.
#WIN Status {$line1}
#WIN Status {$line2}
#WIN Status {$line3}
#WIN Status {$line4}
#WIN Status {$line5}
#WIN Status {$line6}


Is there a way to turn certain parts of this on and off? Such as if someone wants to turn on a certain "plugin", but not another, it'll leave line 4 on, but not line 3? Something without having to go in and change the script each time, but with an alias or #T-?

Thanks!
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Aug 12, 2012 11:50 pm   
 
Sure, just check if the plugin is on before writing to the window. Assuming they're each in a class, it might look something like this:
Code:
#IF (%class("cargoplugin") = 1) {
  $line3 = %format("<color red>Reserved for cargo plugin.</color>")
  #WIN Status {$line3}
  }
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 12:50 pm   
 
Code:

#IF (%class("CargoPlugin") = 1) {
  $line3 = %format("<color red>Planet 1:</color><color lightgrey> &s </color><color red>    Planet 2:</color><color lightgrey> &s </color><color red>    Cargo 1:</color><color lightgrey> &s </color><color red>    Cargo 2:</color><color lightgrey> &s</color>", @CargoPlanet1, @CargoPlanet2, @Cargo1, @Cargo2)
  } {
  $line3 = %format("<color red>Reserved for cargo plugin.</color>")}


This is what I came out with, but I'm just getting:

Code:

ERROR: Syntax error in Function: updatestatuswindow : invalid local variable: line3


The line itself is showing up as the correct format without the variables.
Reply with quote
shalimar
GURU


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

PostPosted: Mon Aug 13, 2012 12:56 pm   
 
before the if statement, add:

#LOCAL $line3
_________________
Discord: Shalimarwildcat
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 1:09 pm   
 
Works great, Shalimar. Thanks much! To get a better hold on this, I'm understanding that it declares it as a variable? What does it do for this script?
Reply with quote
shalimar
GURU


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

PostPosted: Mon Aug 13, 2012 1:23 pm   
 
thats exactly right, local variables need to be declared
if they are only defined inside if statements, they get thrown out when the if is done, due to scoping
_________________
Discord: Shalimarwildcat
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 1:41 pm   
 
Ah, okay. Thanks.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Aug 13, 2012 1:54 pm   
 
In more detail:
Local variables need to be declared before the value is used or tested. The explicit way of declaring local variables is with the #LOCAL command. However, setting the value of a local variable also implicitly declares it. So if you set the value of a local variable (e.g., with "#VAR $varname ..." or "$varname = ...") before the value is ever used or tested, then technically you don't have to use #LOCAL. It is still good programming practice to use #LOCAL even in these cases, if for no other reason than that it helps you remember. It can prevent problems where you initially are setting the value first but later edits introduce situations where the variable is used before it is set.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 3:16 pm   
 
Ah, gotcha. I generally have been using the "$varname = " for alot of the scripts I have been doing, just didn't know exactly what it did, I suppose. Thanks, Rahab.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 3:45 pm   
 
Going back to the config alias, was trying this to make it easier:

Code:

<alias name="xconfig" id="1809">
  <value>$option = %1
#IF ($option = +ShipBuild) {
#T+ ShipBuildPlugin
#PRINT Plugin: Ship Build activated.}
#IF ($option = -ShipBuild) {
#T- ShipBuildPlugin
#PRINT Plugin: Ship Build deactivated.}</value>
</alias>


but get a return of "ERROR: Syntax error in Alias: xconfig : illegal character in expression: +"

Is there a way to allow + and -, or is there no workaround?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Aug 13, 2012 5:14 pm   
 
If you want +ShipBuild to be a literal string, you need to put it in quotes. Without quotes, it's trying to add. In general, you should always put literal strings in quotes, so your alias would look like this:
Code:
<alias name="xconfig" id="1809">
  <value>$option = %1
#IF ($option = "+ShipBuild") {
#T+ "ShipBuildPlugin"
#PRINT "Plugin: Ship Build activated."}
#IF ($option = "-ShipBuild") {
#T- "ShipBuildPlugin"
#PRINT "Plugin: Ship Build deactivated."}</value>
</alias>


If you don't include the quotes that explicitly tell CMUD that you're using a literal string, it tries to figure out what you meant, and will usually get it right (unless you're using certain special characters, like in this case), but including the quotes will make it run faster, and I find it's more readable this way. It might take some getting used to, but you can tell with one glance at that code that +ShipBuild is a literal string that you're expecting as a possible option. Without the quotes, it took me a minute to figure out what you were trying to do (I first thought you wanted +(@ShipBuild) and -(@ShipBuild), ShipBuild being a variable with a number, and you take positive and negative values of it, but that made no sense :P).


Last edited by Daern on Mon Aug 13, 2012 5:23 pm; edited 1 time in total
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon Aug 13, 2012 5:21 pm   
 
Thank you. =) Had to fix it from being a 100% literal string with case issues by changing it to
Code:

(%upper($option) = %upper("+ShipBuild"))
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Aug 14, 2012 4:55 pm   
 
Code:

// Line 4: Reserved for botting plugin I'm working on.
#LOCAL $line4
$line4 = %format("<color red>"["</color><color lightgrey>Botting</color><color red>"]" Time Remaining:</color><color lightgrey> &d:&02d:&02d</color><color red>     Botting Activity: %s", (@BOTTINGTIME / 3600), %mod(@BOTTINGTIME / 60, 60), %mod(@BOTTINGTIME, 60),@BottingActivity)


Have a variable here that runs in seconds, counting up. But I'd like to have it counting down. Is there an easy way to do this? It will always start at 2 hours.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Aug 14, 2012 5:10 pm   
 
We'd need to see how you're setting the variable. If you're using an alarm that fires every second and adds one to the variable, just make it subtract one instead, and instead of starting the variable at 0 start it at 7200 (seconds in two hours).
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Aug 15, 2012 6:25 am   
 
The variable is MSDP. The MUD automatically updates the variable every second.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Aug 15, 2012 7:00 am   
 
All right... just use (7200 - @BOTTINGTIME) instead then.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Aug 15, 2012 9:15 am   
 
I just want to clarify something... CMUD variables most certainly can use underscores. I have several variables in that very format. I do not know where Rahab got the idea that variables cannot, so the MSDP should work. *shrug*

Aliases also allow underscores, by the way.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Aug 15, 2012 12:28 pm   
 
Hm. I've had problems with it in the past, and I vaguely recollect others having problems with underscores in variables too. I'll check again.
Reply with quote
glister
Beginner


Joined: 06 Mar 2014
Posts: 12

PostPosted: Tue Dec 31, 2019 8:21 pm   MSDP Information
 
So I put this together this will initialize MSDP on any mud and setup reporting for every available msdpvar

Code:
<class name="Initialize" id="209">
  <trigger type="Telnet" param="69" priority="10" regex="true" id="208">
    <pattern>[\x01]REPORTABLE_VARIABLES[\x02][\x05][\x02]</pattern>
    <value>#T+ BeginInit

</value>
  </trigger>
  <trigger name="BeginInit" type="Telnet" param="69" priority="11" repeat="true" regex="true" enabled="false" id="210">
    <pattern>[\x02]([a-z,_,\s]+)</pattern>
    <value>#SENDSB 69 %CHAR(1)REPORT%CHAR(2)%1
#T- BeginInit</value>
  </trigger>
  <alias name="LoadMSDP" id="211">
    <value>#sendsb 69 %CHAR(1)LIST%CHAR(2)REPORTABLE_VARIABLES
</value>
  </alias>
</class>


This one has two sets of triggers. The main ones parses through all of the msdp vars and maps them to variables. The second one puts all of the values of a sublist called group into a CMUD varaible database record. This can be used to capture content out of any custom lists that may be setup on your mud. Keep in mind you will need to modify this to work with the specific sublist.
Code:
<class name="Prod" id="189">
  <trigger name="Main" type="Telnet" param="69" priority="19" regex="true" newline="false" prompt="true" id="113">
    <pattern>^[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#clr Combat</value>
  </trigger>
  <trigger name="Main2" type="Telnet" param="69" priority="20" regex="true" newline="false" prompt="true" id="195">
    <pattern>^[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#VAR %1 %2

#Win Combat Tank: @Tank_Name
#Win Combat Enemy: @OPPONENT_NAME HP: @OPPONENT_HEALTH/@OPPONENT_Health_MAX</value>
  </trigger>
  <trigger type="Telnet" param="69" priority="1990" regex="true" id="199">
    <pattern>[\x01](GROUP)[\x02][\x05][\x02][\x03]</pattern>
    <value>CurMSDPTable = %1
#T+ GroupOpen
MSDPCounter = 1

</value>
  </trigger>
  <trigger name="GroupOpen" type="Telnet" param="69" priority="1991" repeat="true" regex="true" enabled="false" id="201">
    <pattern>[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#ADDKEY @curMSDPTable @MSDPCounter {%1|%2}
MSDPCounter = @MSDPCounter + 1

#clr group
GroupSize = @MSDPCounter
#T+ GroupClose
</value>
  </trigger>
  <trigger name="GroupClose" type="Telnet" param="69" priority="1992" regex="true" enabled="false" id="202">
    <pattern>[\x01](GROUP)[\x02][\x05][\x02][\x03].*[\x04][\x06]</pattern>
    <value>//#say g2 activeated

//               NAME         

A = 1
#WHILE (@A < @GroupSize) {
#win Group @GROUP.@A.2 LvL:@GROUP.%eval(@A+1).2
#win Group HP:@GROUP.%eval(@A+3).2/@GROUP.%eval(@A+4).2 MV:@GROUP.%eval(@A+5).2;#ADD A 7}

//#win Group @GROUP.1.2 LvL:@GROUP.2.2 HP:@GROUP.4.2/@GROUP.5.2 MV:@GROUP.6.2

#T- GroupOpen
#T- GroupClose</value>
  </trigger>
</class>


Please note: The group triggers also have the syntax for pulling information out of the database variable. I'm pushing information to a windows named group. All of that isn't necessary however I left it here to have a great example of how it works.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
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