*** PSEUDO CODE NOT TESTED***
the infinite Loop problem is because text-=Text is put into both the plugin and the action. it cannot be this way. text=Text has to be in the plugin and in the action you do nothing
but the Text class has to be done differently when this is done.
You cannot do
Code: Select all
class Text:
var1 = 'blah'
var2 = 'blah2'
and have the action be able to access var1 and var2
there are 2 ways around this.
if you only need to access var1 and var2 from that specific action you will need to do this
Code: Select all
class Text:
class SAME_NAME_AS_ACTION:
var1 = 'blah'
var2 = 'blah2'
that will point to the action properly and can be accessed from inside of the action as self.text
now if you need to have access to var1 and var 2 from more then one action. you will have to subclass eg.TranslatableStrings this way the translation takes place before the plugin gets it's hands on it and that translation can be used elsewhere
Code: Select all
class Text(eg.TranslatableStrings):
var1 = 'blah'
var2 = 'blah2'
and to access this from the actions as self.text you will have to point to the Text class directly. But still
*****DO NOT**** set the text = Text in the class for the action. you can do this in a method. but not at the class level for the action
Code: Select all
class SOME_PLUGIN(eg.PluginClass):
# NO NO NO NO
text = Text()
# YES YES YES YES
text = Text
class SOME_ACTION(eg.AcrionClass):
# NO NO NO NO
text = Text
def Configure(self):
# YES YES YES YES
text = self.text
# or this if you subclassed eg.TranslatableStrings
text = Text
I really do hope this clears this up for everyone that is in confusion as to how the whole Text class things works.
But I am going to throw in a winger for ya
If you specify a Text class in the plugin. you cannot use the name and description in the action anymore.
It has to be done like so. you do how ever specify the icon in the action if you have an icon for the action.
Code: Select all
class Text:
class SAME_NAME_AS_ACTION:
name = 'Some Action Name
description = 'Some Actions Description
so to wrap this up.
I will always put the eg.TranslatableStrings in the Text class. this is because I just never know if there is something i may want to access directly. and it's just a good habit to identify it as well.
because in the reality of things you can name the class HokeyPokey if you wanted
Code: Select all
class HokeyPokey:
var1 = 'test'
class Some_Plugin(eg.PluginClass):
text = HokeyPokey
but there is no means to Identify what HokeyPokey is or what it does. that is why it is good practice
here is a complete proper way to use this
Code: Select all
import eg
eg.RegisterPlugin(name='Text Class Demo')
class Text(eg.TranslatableStrings):
pluginTest = 'test'
action2Test = 'test'
class Action1:
name = 'Action Name 1'
description = 'Action 1 Description'
action1Test = 'test'
class Action2:
name = 'Action Name 2'
description = 'Action 2 Description'
class PLUGIN(eg.PluginClass):
text = Text
def __init__(self):
self.AddAction(Action1)
self.AddAction(Action2)
def __start__(self):
text = self.Text
print text.pluginTest
class Action1(eg.ActionClass):
def __call__(self):
text = self.Text
print text.name
print text.description
print text.action1Test
class Action2(eg.ActionClass):
def __call__(self):
text = Text
print text.action2Test
text = self.Text
print text.name
print text.description
print text.action2Test
Thank You all and Have a Nice Day
