Set/Get Attribute
-
Attributes acts like a file for each model.
When we call
eval(some attribute)
, it is similar to taskload(file)
.
Am I thinking right?**If do then:**I was disturbed or in better words got stuck by the idea of how scripts are writen in sketchy physics. The thing that disturbed me was the miss-use of variables:
` onstart{
@things = []
@count = 0
@hello = 10def getEntByName(name)
...
end
}`Creating instance varibales outside of class doesn't report errors, but they just act like global variables. For instance: I assign instance varible
@count = 10
, outside of class, in some attribure and eval the attribute. Then I set_attribute@count
for another model and eval it too. The evaluation of second attribute would return me "10", but not the error that I expected. I don't understand how attributes work. If I eval it, does it even becomes defined in the plugin files? I need some explanation on that, I'm stuck. -
You are confusing RUBY attributes (aka instance variables,) with SKP dictionary attributes (aka data fields.)
They are not the same thing, although both can be called attributes.
-
So, its the right way to use
@
kind of variables in Attribute Dictionary? -
@anton_s said:
So, its the right way to use
@
kind of variables in Attribute Dictionary?They are not related in any way. Maybe it would be best if you described what you are trying to achieve?
-
@thomthom said:
@anton_s said:
So, its the right way to use
@
kind of variables in Attribute Dictionary?They are not related in any way. Maybe it would be best if you described what you are trying to achieve?
It's the scripts that confuse me in sketchy physics 'onTick' or 'scripted' fields.
Examining someones script, like Mr.k's or Wacov's, I usualy find instance variables that are not assigned and used in the class, but are writen outside of class, like local or global variables. The example is in my first post. I want to know if it is the right way to write scripts like they did, using instance variables as the variables. -
Not in the global Objectspace, no...
... all your code should be inside your unique toplevel module, and all your classes should be inside that as well.
-
@dan rathbun said:
Not in the global Objectspace, no...
... all your code should be inside your unique toplevel module, and all your classes should be inside that as well.
Okay, that's what I thought. It was just the wrong use of variables, and people who were learning ruby from sketchy physcics scripts did the same thing, so now I know, Thanks
Advertisement