Hello from the U.K !
I am learning Lua (as my first scripting language) and I have this script as a plugin (.xml) for MUSHclient:
Quote:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="FINAL_GOLD_AUC_LUANEWB"
author="Luanewb"
id="bd6a63354eec6157b8088351"
language="Lua"
purpose="GOLD_AUC_TRACKER"
save_state="y"
date_written="2100-12-12 12:12:12"
requires="4.93"
version="1.0"
>
<description trim="n">
<![CDATA[
]]>
</description>
</plugin>
<include name="constants.lua"/>
<aliases>
<alias
match="^vars$"
enabled="y"
regexp="y"
send_to="12"
omit_from_output="y"
script="ShowVariables"
sequence="100"
>
</alias>
</aliases>
<triggers>
<trigger
match="^{chan ch=auction}Auction: (?<item>.*?) SOLD to (?<player>\w+) for (?<gold>[0-9,]+) gold\.$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
script="RecordSale"
>
</trigger>
</triggers>
<script>
<![CDATA[
local item_name = GetVariable("item_name") or ""
local player_name = GetVariable("player_name") or "Luanewb"
local gold_amount = GetVariable("gold_amount") or 0
function RecordSale (name, line, wildcards)
item_name = wildcards.item
if (wildcards.player == player_name) then
local num_no_commas = string.gsub(wildcards.gold, ",", "")
gold_amount = tonumber(gold_amount) + tonumber(num_no_commas)
end
end
function ShowVariables ()
Note("Player Name: " .. player_name)
Note("Last Item Sold: " .. item_name)
Note("Total Gold: " .. gold_amount)
end
function OnPluginSaveState()
SetVariable("item_name", item_name)
SetVariable("player_name", player_name)
SetVariable("gold_amount", gold_amount)
end
]]>
</script>
</muclient>
which works just fine however I'm looking to add some code to it to make it also track gold received from items sold by a particular player (self)
so I'm guessing it would be something like this in the triggers tags and the script tags:
Quote:
<triggers>
<trigger
match="^{chan ch=auction}Auction: (?<item>.*?) SOLD to (?<player>\w+) for (?<gold>[0-9,]+) gold\.$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
script="RecordAucBought"
>
</trigger>
<trigger
match="^{chan ch=auction}Auction: (?<player>\w+) is auctioning (?<item>.*?) (level (?<item_level>.*?), Num (?<item_number>.*?)). Current bid is (?<gold>[0-9,]+)\.$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
script="RecordAucSold"
>
</trigger>
</triggers>
<script>
<![CDATA[
local player_name = GetVariable("player_name") or "Luanewb"
local gold_auc_bought = GetVariable("gold_auc_bought") or 0
local gold_auc_sold = GetVariable("gold_auc_sold") or 0
function RecordAucbought (name, line, wildcards)
item_name = wildcards.item
if (wildcards.player == player_name) then
local num_no_commas = string.gsub(wildcards.gold, ",", "")
gold_auc_bought = tonumber(gold_auc_bought) + tonumber(num_no_commas)
end
end
function RecordAucSold (name, line, wildcards)
item_name = wildcards.item
if (wildcards.player == player_name) then
local num_no_commas = string.gsub(wildcards.gold, ",", "")
gold_auc_sold = tonumber(gold_auc_sold) + tonumber(num_no_commas)
end
end
function ShowVariables ()
Note("Total Gold Spent On Auction: " .. gold_auc_bought)
Note("Total Gold Received From Auction: " .. gold_auc_sold)
end
function OnPluginSaveState()
SetVariable("gold_auc_bought", gold_auc_bought)
SetVariable("gold_auc_sold", gold_auc_sold)
end
]]>
</script>
except I need to capture the amount the item actually sold for several lines of MUD output AFTER the trigger fires. (the amount the item eventuall sold for) I'm guessing I need some sort of trigger within a trigger mechanic? Is that even possible?? I hope so! :)
Please Help ! |