Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Problem loading variables
|
Problem loading variables
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| LezChap
(36 posts) Bio
|
| Date
| Mon 29 Mar 2010 03:32 AM (UTC) Amended on Mon 29 Mar 2010 03:33 AM (UTC) by LezChap
|
| Message
| I have a plugin script similar to the following (just a snippit of the problem areas):
<trigger
enabled="y"
keep_evaluating="y"
match="^Welcome back, (.+)\.$"
name="TriggerWelcomeBack"
regexp="y"
send_to="12"
sequence="100"
>
<send>
SetTableName("%<1>")</send>
</trigger>
function SetTableName(TableName)
TableName = string.gsub (TableName, "[^%a%d]", "_") --replace all non-letters or numbers with _
if TableName ~= dbTable then
dbTable = TableName
SetVariable ("DBTable", dbTable)
end
ColourNote("Cyan","black", "Using "..dbTable.."'s data as the Current Data for People_Met Plugin.")
end --function
function Start()
dbTable = "Table"
local dbTableCheck = GetVariable("DBTable")
if dbTableCheck ~= nil and dbTableCheck ~= "" then
SetTableName(dbTableCheck)
end
end --function
function OnPluginInstall ()
Start()
end -- OnPluginInstall
function OnPluginEnable ()
Start()
end -- OnPluginEnable
Problem is when Start() finds a valid value in DBTable, and sends it to SetTablename(), the script seems to stop working as it should...Notes and Tells that the script should send to the mud window stop working. Variables are still set and updated, however.
It seems like the problem is on the "SetVariable" line (debugging and commenting out code), but I can't figure out how to fix it. Any ideas? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 29 Mar 2010 03:51 AM (UTC) |
| Message
| Right, so in a somewhat roundabout way, your script is setting the variable "DBTable" to whatever name appeared in the trigger?
So what goes wrong, exactly? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| LezChap
(36 posts) Bio
|
| Date
| Reply #2 on Mon 29 Mar 2010 04:02 AM (UTC) Amended on Mon 29 Mar 2010 04:03 AM (UTC) by LezChap
|
| Message
| It does that part just fine...if the trigger goes off after the script it freshly installed (with no save state), it runs through the whole thing fine, and does the ColourNote, as well as the rest of the script. If the trigger goes off again, it's still fine.
Now when I close the world, and re-open it, it should read the Variable, send it to SetTableName() and display the ColourNote...It does the first part just fine (loads the variable and sends it to SetTableName()), but the script stops displaying the ColourNote (and all other Notes, ColourNotes, Tells, and ColourTells in the script). If the trigger matches, it'll parse the name in the trigger to SetTableName(), but still fail to display and Notes/Tells.
Another thing I noticed is when it's failing to display Notes and Tells, the text entered in "Test Trigger..." changes from the default gray it used to display as, to the blue color that is the same as the default for Notes. (Currently only doing offline testing) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Mon 29 Mar 2010 04:25 AM (UTC) |
| Message
| Ah, OK I see.
At world startup the plugins are loaded before the main window is initialized. Thus any world notes very early on are simply discarded.
The work around is to delay that processing slightly, for example something like this:
function OnPluginInstall ()
DoAfterSpecial (1, "Start()", sendto.script)
end -- OnPluginInstall
And I wouldn't really bother doing it on the plugin enable, what will that achieve? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
15,880 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top