|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sun Mar 13, 2011 1:57 am
[3.33 Bug Report] %context and %class are switched |
The help file says:
%class name of current default class
%context retrieve the name of the class executing the script (added in v2.12)
%module retrieve the name of the current module executing the script (added in v2.12)
Code: |
<cmud>
<class name="TestClass" copy="yes">
<event event="TestEvent" priority="1340" copy="yes">
<value>#SAY Event - module: %module | context: %context | class: %class</value>
</event>
<alias name="Test" copy="yes">
<value>#CLASS 0
#SHOW TestTrigger
#SAY Alias - module: %module | context: %context | class: %class
#RAISE TestEvent
#CALL @TestFunction()
#SAY "// Manually changing class."
#CLASS FooBar
#SHOW TestTrigger
#SAY Alias - module: %module | context: %context | class: %class
#RAISE TestEvent
#CALL @TestFunction()
#CLASS 0</value>
</alias>
<trigger priority="550" copy="yes">
<pattern>^TestTrigger</pattern>
<value>#SAY Trigger - module: %module | context: %context | class: %class</value>
</trigger>
<func name="TestFunction" copy="yes">
<value>#SAY Function - module: %module | context: %context | class: %class</value>
</func>
</class>
</cmud> |
Type 'test' and all of the objects will correctly report their %module then erroneously mix up their %context and %class. These are reported with the #CLASS first set manually to 0, then set manually to 'foobar'. If you install this snippit of code in to a different package entirely, %module will correctly return the name of that package. So as far as I can tell, %module is doing what it's supposed to do, %context and %class have been switched.
My output:
Code: |
TestTrigger
Trigger - module: TestPackage | context: MyMUD | class: TestPackage|TestClass
Alias - module: TestPackage | context: MyMUD | class: TestPackage|TestClass
Event - module: TestPackage | context: MyMUD | class: TestPackage|TestClass
Function - module: TestPackage | context: MyMUD | class: TestPackage|TestClass
// Manually changing class.
TestTrigger
Trigger - module: TestPackage | context: MyMUD|FooBar | class: TestPackage|TestClass
Alias - module: TestPackage | context: MyMUD|FooBar | class: TestPackage|TestClass
Event - module: TestPackage | context: MyMUD|FooBar | class: TestPackage|TestClass
Function - module: TestPackage | context: MyMUD|FooBar | class: TestPackage|TestClass |
|
|
Last edited by DraxDrax on Mon Mar 14, 2011 10:52 pm; edited 1 time in total |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Mon Mar 14, 2011 10:51 pm |
Renamed and bumped. I should probably have been clearer that this was a bug report in the first place.
|
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Thu Apr 07, 2011 11:13 pm |
Can this be added to the official bug list, or might someone let me know if it's already in the list?
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Apr 08, 2011 1:37 am |
No, actually your results are correct. The %class always reports "TestPackage|TestClass" because that is the class that the alias, triggers, etc is within. Using the #CLASS command doesn't change the parent class of these scripts. Using the #CLASS command changes the runtime "class context" as properly reported by %context.
I think it's actually the help file that is confusing about this. But in general it's the %context that will always be changing, not the %class. |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sat Apr 09, 2011 5:48 am |
Well that's good. I was concerned about including these variables in scripts, only to have the behavior change on me at a later date when that confusion was sorted out. If it's the help file that needs fixing rather than the variables, I don't need to worry.
|
|
|
|
|
|