[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  scripting: "appending" words to a variable?

scripting: "appending" words to a variable?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by SKYY   (28 posts)  [Biography] bio
Date Thu 03 Apr 2008 06:31 PM (UTC)
Message
First of all, I've finished my first ever lua-type script/trigger/plugin for MUSHclient! (I'm so happy, heh)

It does what I want, but I'd like to polish it up in a certain way.

It's a stat reroller for a smaug mud. It functions perfectly. However, I also have it spamming out ColourNotes whenever a stat is rolled at or above the desired amount, and each of these stat ColourNotes appear on a new line.

Is there a way to create some sort of variable, and append each ColourNote to that variable, so that I can put all the output on ONE line, vice seven?

I've saved it as a plugin (including the 7 stat variables). I didn't think about it before making it a plugin--but by adding the variables, I take away all GUI-based editing for those variables. That's just a minor annoyance.

Here it is. Any pointers would be gladly appreciated, as I'm not much of a programmer!

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, April 03, 2008, 11:12 AM -->
<!-- MuClient version 4.23 -->

<!-- Plugin "SMAUG_Reroller" generated by Plugin Wizard -->

<muclient>
<plugin
name="SMAUG_Reroller"
author="SKYY"
id="26aeadabb6c27a7ef1c9ae7e"
language="Lua"
purpose="Rerolls SMAUG 1.8 stats based on desired abilities."
save_state="y"
date_written="2008-04-03 11:10:42"
requires="4.23"
version="1.0"
>
<description trim="y">
<![CDATA[
This plugin rerolls stats for SMAUG 1.8 muds. It outputs the seven stats in their own colors as it rolls, so that the user can clearly see which stats are above the desired levels. This allows the user to get a general idea of any requested stat levels which may be too high.

Set the seven stat variables by editing the plugin, and changing the numbers in the variables at the bottom of the text file.
]]>
</description>

</plugin>


<!-- Get our standard constants -->

<include name="constants.lua"/>

<!-- Triggers -->

<triggers>
<trigger
enabled="y"
expand_variables="y"
group="ReRoll"
lines_to_match="2"
match="^Str: (\d{1,2}) Int: (\d{1,2}) Wis: (\d{1,2}) Dex: (\d{1,2}) Con: (\d{1,2}) Cha: (\d{1,2}) Lck: (\d{1,2})$"
name="ReRoll"
regexp="y"
send_to="12"
sequence="100"
>
<send>if %1&gt;=tonumber(GetVariable("str"))
then
ColourNote("#ff3030","","STR: ","#ff3030","",%1)
else
ColourNote("#ff3030","","STR:")
end

if %2&gt;=tonumber(GetVariable("int"))
then
ColourNote("#ccaaff","","INT: ","#ccaaff","",%2)
else
ColourNote("#ccaaff","","INT:")
end

if %3&gt;=tonumber(GetVariable("wis"))
then
ColourNote("#30ffff","","WIS: ","#30ffff","",%3)
else
ColourNote("#30ffff","","WIS:")
end

if %4&gt;=tonumber(GetVariable("dex"))
then
ColourNote("#30ff30","","DEX: ","#30ff30","",%4)
else
ColourNote("#30ff30","","DEX:")
end

if %5&gt;=tonumber(GetVariable("con"))
then
ColourNote("#ffaa30","","CON: ","#ffaa30","",%5)
else
ColourNote("#ffaa30","","CON:")
end

if %6&gt;=tonumber(GetVariable("cha"))
then
ColourNote("#77aaff","","CHA: ","#77aaff","",%6)
else
ColourNote("#77aaff","","CHA:")
end

if %7&gt;=tonumber(GetVariable("lck"))
then
ColourNote("#ffffaa","","LCK: ","#ffffaa","",%7)
else
ColourNote("#ffffaa","","LCK:")
end

if %1&gt;=tonumber(GetVariable("str")) and %2&gt;=tonumber(GetVariable("int")) and %3&gt;=tonumber(GetVariable("wis")) and %4&gt;=tonumber(GetVariable("dex")) and %5&gt;=tonumber(GetVariable("con")) and %6&gt;=tonumber(GetVariable("cha")) and %7&gt;=tonumber(GetVariable("lck"))
then
&#9;Send("y")
else
&#9;Send("n")
end</send>
</trigger>
</triggers>

<!-- Variables -->

<variables>
<variable name="str">15</variable>
<variable name="int">18</variable>
<variable name="wis">18</variable>
<variable name="dex">14</variable>
<variable name="con">14</variable>
<variable name="cha">3</variable>
<variable name="lck">15</variable>
</variables>

</muclient>


[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 03 Apr 2008 08:42 PM (UTC)
Message
Quote:

Is there a way to create some sort of variable, and append each ColourNote to that variable, so that I can put all the output on ONE line, vice seven?



Use ColourTell to output a note not terminated by a newline, and then another one to add more stuff, and so on, finally ending up with ColourNote (or just Note) to finish the line off.

http://www.gammon.com.au/scripts/doc.php?function=ColourTell

eg.

ColourTell / ColourTell / ColourTell / ColourTell / ColourNote

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 03 Apr 2008 10:28 PM (UTC)
Message
Also, in Lua you can concatenate strings, like this:


v = "Hello "
v = v .. "there "
v = v .. "everyone"
print (v)  --> Hello there everyone


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by SKYY   (28 posts)  [Biography] bio
Date Reply #3 on Fri 04 Apr 2008 02:15 AM (UTC)
Message
concatenate! that's the word I was looking for. Thanks nick--once again.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,888 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]