hello.
how i can create static variables in Hscript ?
like C++
static float myVar = 10.0f;
for example i want create a static variables by default value 10,then i want increases this variables in each time and send to TY from my object.
my custom Hscript :
{
static test = 10; //syntax error
test++;
return test;
}
Static variables in HScript
5513 6 2- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
- Pagefan
- Member
- 519 posts
- Joined:
- Offline
- WhoDjini
- Member
- 94 posts
- Joined: Dec. 2008
- Offline
Pagefan
Why does it have to be static?
No offence pagefan, just ignore it, if you know the concept of static vars…
A static var is needed, when you want to have a local var, that keeps its value over several calls of a function…
( ops: Way too common to me to explain it properly… ops: )
If you can't script/program it, it's no good at all !
- rdg
- Member
- 401 posts
- Joined:
- Offline
Thanks for the explanation WhoDjini.
No Houdini doesn't have static variables as far as I know. Because it doesn't work that way.
If you want to increment the position of an object over time you have several options, including:
Use $TX + $F
Use chops
Use DOPs
Use POPs.
SOPs are procedural and don't have the concept of ‘memory’.
No Houdini doesn't have static variables as far as I know. Because it doesn't work that way.
If you want to increment the position of an object over time you have several options, including:
Use $TX + $F
Use chops
Use DOPs
Use POPs.
SOPs are procedural and don't have the concept of ‘memory’.
this is not a science fair.
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
Ok .thanks.
i want create a variable by default value 1.when condition function equal to True , i want decrease the variable in each Frame.
for example :
{
myVar = 1;//i want just on time this variable setting up !
if($F>10)
myVar = myVar - 0.1;
out = clamp(myVar,0,1);
return out;
}
but in each frame again myVar = 1 !
i want create a variable by default value 1.when condition function equal to True , i want decrease the variable in each Frame.
for example :
{
myVar = 1;//i want just on time this variable setting up !
if($F>10)
myVar = myVar - 0.1;
out = clamp(myVar,0,1);
return out;
}
but in each frame again myVar = 1 !
- Pagefan
- Member
- 519 posts
- Joined:
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
-
- Quick Links