ShiVa3D
Interpolating HUD Opacity issues in StoneScript [SOLVED]
All about the StoneScriptInterpolating HUD Opacity issues in StoneScript
by totellity » 27 Apr 2012, 14:13
Hi Stonetrip,
I'm not sure if anyone has encountered the problem of the interpolate opacity command not working at all in script. It works directly on the HUD when the action is added to the HUD actions but does not for me when it is called in script instead. The command is the;
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hud.pushActionCommandArgument ( hAction, hComponent )
hud.pushActionCommandArgument ( hAction, nInterpolate )
hud.pushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hud.pushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
After executing this command, nothing seems to happen. However, it works fine when I use the interpolate opacity action command directly on the HUD.
I'm not sure if anyone has encountered the problem of the interpolate opacity command not working at all in script. It works directly on the HUD when the action is added to the HUD actions but does not for me when it is called in script instead. The command is the;
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hud.pushActionCommandArgument ( hAction, hComponent )
hud.pushActionCommandArgument ( hAction, nInterpolate )
hud.pushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hud.pushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
After executing this command, nothing seems to happen. However, it works fine when I use the interpolate opacity action command directly on the HUD.
- totellity
- Fresh Boarder

- Posts: 7
Re: Interpolating HUD Opacity issues in StoneScript
by broozar » 27 Apr 2012, 14:42
hello totellity,
hComponent is probably not correct. at least i made this mistake when i started using HUDs. what is its value?
A simple "prefix.component" won't do it, you need a full hud.getComponent ( hUser, "prefix.component").
also, i miss newAction on top of the codeblock, i assume you just didn't copy it, nevertheless.
another possibility, the action is simply not called. what code do you use to call it?
hComponent is probably not correct. at least i made this mistake when i started using HUDs. what is its value?
A simple "prefix.component" won't do it, you need a full hud.getComponent ( hUser, "prefix.component").
also, i miss newAction on top of the codeblock, i assume you just didn't copy it, nevertheless.
another possibility, the action is simply not called. what code do you use to call it?
Re: Interpolating HUD Opacity issues in StoneScript
by totellity » 27 Apr 2012, 19:34
Hi Broozar,
Thanks for the quick response. Please see the entire script below:
--LOCAL FUNCTIONS
local hudPushActionCommandArgument = hud.pushActionCommandArgument
--LOCAL VARIABLES
local hUser = application.getCurrentUser ( )
local hAction = hud.getAction ( hUser,"Interpolate" )
--local hComponent = hud.getComponent ( hUser, "Options."..sOptionTag )
local hComponent = hud.getComponent ( hUser, sOptionTag )
--INTERPOLATING THE OPACITY OF HUDS
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hud.pushActionCommandArgument ( hAction, hComponent )
hud.pushActionCommandArgument ( hAction, nInterpolate )
hud.pushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hud.pushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
The prefix in this case is "Options.". In fact, if the prefix was wrong I would get an error in the effect of - parameter 1 is "nil." However, all the functions run and I still get no output on the HUD.
Thanks for the quick response. Please see the entire script below:
--LOCAL FUNCTIONS
local hudPushActionCommandArgument = hud.pushActionCommandArgument
--LOCAL VARIABLES
local hUser = application.getCurrentUser ( )
local hAction = hud.getAction ( hUser,"Interpolate" )
--local hComponent = hud.getComponent ( hUser, "Options."..sOptionTag )
local hComponent = hud.getComponent ( hUser, sOptionTag )
--INTERPOLATING THE OPACITY OF HUDS
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hud.pushActionCommandArgument ( hAction, hComponent )
hud.pushActionCommandArgument ( hAction, nInterpolate )
hud.pushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hud.pushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
The prefix in this case is "Options.". In fact, if the prefix was wrong I would get an error in the effect of - parameter 1 is "nil." However, all the functions run and I still get no output on the HUD.
- totellity
- Fresh Boarder

- Posts: 7
Re: Interpolating HUD Opacity issues in StoneScript
by NiCoX » 27 Apr 2012, 20:15
Hi,
Here is a working example, based on your code:
http://developer.stonetrip.com/Download/Misc/TEST_HUDActionInScript_20120427.ste

Here is a working example, based on your code:
http://developer.stonetrip.com/Download/Misc/TEST_HUDActionInScript_20120427.ste
-

NiCoX - Platinum Boarder

- Posts: 5626
- Location: France
Re: Interpolating HUD Opacity issues in StoneScript
by totellity » 30 Apr 2012, 17:04
Hi NiCox,
Thanks for the update. I tried to implement the function as you had provided and it does work but with some issues. Here is the updated function:
--LOCAL FUNCTIONS
local hudPushActionCommandArgument = hud.pushActionCommandArgument
--LOCAL VARIABLES
local hUser = application.getCurrentUser ( )
local hAction = hud.getAction ( hUser, "Options.Interpolate" )
local hComponent = hud.getComponent ( hUser, sOptionTag )
--INTERPOLATING THE OPACITY OF HUDS
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hudPushActionCommandArgument ( hAction, hComponent )
hudPushActionCommandArgument ( hAction, nInterpolate )
hudPushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hudPushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
hud.callAction ( hUser, "Options.Interpolate" )
As you can see, by adding the callAction function at the end of the script allows the HUD as required, however, the hud.PushActionCommandArgument is not resetting itself when the command ends. For example, if the following script is called:
this.HUDDisplay ( "Options.GeneralGraphicsButton", 255, 500 )
this.HUDDisplay ( "Options.GeneralSoundButton", 255, 500 )
this.HUDDisplay ( "Options.GeneralAdvancedButton", 255, 500 )
It works fine the first time. However, if it is called again, new arguments are added to the list of arguments and the action calls the interpolater twice and if it is called a third time the same arguments are added again to the end of the arguments list.
My question is, how can I reset the actions argument list so that the same action won't be called multiple times?
Thanks for the update. I tried to implement the function as you had provided and it does work but with some issues. Here is the updated function:
--LOCAL FUNCTIONS
local hudPushActionCommandArgument = hud.pushActionCommandArgument
--LOCAL VARIABLES
local hUser = application.getCurrentUser ( )
local hAction = hud.getAction ( hUser, "Options.Interpolate" )
local hComponent = hud.getComponent ( hUser, sOptionTag )
--INTERPOLATING THE OPACITY OF HUDS
hud.beginActionCommand ( hAction, hud.kCommandTypeInterpolateOpacity )
hudPushActionCommandArgument ( hAction, hComponent )
hudPushActionCommandArgument ( hAction, nInterpolate )
hudPushActionCommandArgument ( hAction, hud.kInterpolatorTypeLinear )
hudPushActionCommandArgument ( hAction, nTime )
hud.endActionCommand ( hAction )
hud.callAction ( hUser, "Options.Interpolate" )
As you can see, by adding the callAction function at the end of the script allows the HUD as required, however, the hud.PushActionCommandArgument is not resetting itself when the command ends. For example, if the following script is called:
this.HUDDisplay ( "Options.GeneralGraphicsButton", 255, 500 )
this.HUDDisplay ( "Options.GeneralSoundButton", 255, 500 )
this.HUDDisplay ( "Options.GeneralAdvancedButton", 255, 500 )
It works fine the first time. However, if it is called again, new arguments are added to the list of arguments and the action calls the interpolater twice and if it is called a third time the same arguments are added again to the end of the arguments list.
My question is, how can I reset the actions argument list so that the same action won't be called multiple times?
- totellity
- Fresh Boarder

- Posts: 7
Re: Interpolating HUD Opacity issues in StoneScript
by totellity » 03 May 2012, 13:41
Hi Guys,
I'm still going along with putting all the actions in the HUD instead of in the script. For example, in the screenshot attached I had hoped to include the commands in script to control my HUD but unfortunately because of the previously stated issue I am keeping it as part of the HUD. If there are any development on this issue, please let me know, otherwise thanks for the help.
I'm still going along with putting all the actions in the HUD instead of in the script. For example, in the screenshot attached I had hoped to include the commands in script to control my HUD but unfortunately because of the previously stated issue I am keeping it as part of the HUD. If there are any development on this issue, please let me know, otherwise thanks for the help.
- Attachments
-
- Actions in HUD instead of in Script
- HUD Actions.jpg (161.44 KiB) Viewed 1293 times
- totellity
- Fresh Boarder

- Posts: 7
Re: Interpolating HUD Opacity issues in StoneScript
by broozar » 04 May 2012, 21:22
why do you get an action from the HUD (hud.getAction ( hUser, "Options.Interpolate" )) if you are going to change it later by code? why not define an entire action in code? ( http://www.stonetrip.com/developer/doc/api/hud-newAction ) because every newAction command creates a new hAction handle that acts like the "reset" you try to achieve.
Re: Interpolating HUD Opacity issues in StoneScript
by TRANE23 » 09 May 2012, 10:53
That's because your are not doing this the good way.Because what you do is creating the action each time you call HUDDisplay.
If I understand you want to create an action in script and call a script function "HUDDisplay" with runtime argument to control the action.
You have to create your action one time (on init for example) using hud.pushActionCommandRuntimeArgument and when you want to use the action in your function HUDDisplay you write hud.callAction(this.getuser(),"sPrefix.Myaction",nRuntimeArg1,nRuntimeArg2,..,)
That's all.
Or as Broozar said create the action via HUD preview. It's the same but faster than writing code. And just Call your action via script with hud.callAction. Don't forget to put runtime Value for the parameter type.

If I understand you want to create an action in script and call a script function "HUDDisplay" with runtime argument to control the action.
You have to create your action one time (on init for example) using hud.pushActionCommandRuntimeArgument and when you want to use the action in your function HUDDisplay you write hud.callAction(this.getuser(),"sPrefix.Myaction",nRuntimeArg1,nRuntimeArg2,..,)
That's all.
Or as Broozar said create the action via HUD preview. It's the same but faster than writing code. And just Call your action via script with hud.callAction. Don't forget to put runtime Value for the parameter type.
- TRANE23
- Senior Boarder

- Posts: 54
- Location: France
Re: Interpolating HUD Opacity issues in StoneScript
by vklymenko » 09 May 2012, 20:17
just a note: sometimes Im doing like this:
hud.pushActionCommandArgument ( action, math.roundToNearestInteger(val) )
because "val" can be "float", but should be "integer". I know its all "number" in the script, but it saving me much of time for bugs fixing, because it can cause logical issues also.
hud.pushActionCommandArgument ( action, math.roundToNearestInteger(val) )
because "val" can be "float", but should be "integer". I know its all "number" in the script, but it saving me much of time for bugs fixing, because it can cause logical issues also.
Re: Interpolating HUD Opacity issues in StoneScript [SOLVED]
by totellity » 18 Jul 2012, 16:09
Thanks Guys,
My mistake was that I wasn't calling the action with the arguments as shown by TRANE23. Seems to be working fine now. Will contact you if there are any other issues.
My mistake was that I wasn't calling the action with the arguments as shown by TRANE23. Seems to be working fine now. Will contact you if there are any other issues.
- totellity
- Fresh Boarder

- Posts: 7
10 posts
• Page 1 of 1