1
Newbie Coding / Scripting questions, don't know if that constitutes coding
« on: February 15, 2010, 12:34:44 am »
So, I am a Newb and would like to study the game and have decided to start with scripting since that seems to be the easiest and the most visible in regards to having more instant visual feedback. I figure I should try to learn how to crawl before trying to learn how to run.
So I checked out the documentation on the wiki and have more questions.
A user requested a modification and I wanted to see what it would entail to make a user modification for it. The request was to add checkboxes next to the effects_str and the music_str to turn them off and on similar to the checkbox sound_init node. He posted a pic here: http://ufoai.ninex.info/forum/index.php?topic=4428.msg33974#msg33974
I added the checkboxes and have obtained general functionality, but I am not satisfied with my results and have generated a few questions, which I find to be a positive thing as my primary interest is more in studying than making this work.
This works well enough in regards to setting the volume to 0.0 when it is unchecked.
However I run into a couple of various concerns and snags:
1. When I re-check the checkbox from an unchecked state, each of the volumes respond differently.
a. The effects volume is changed to 1.0 I would assume, ie. it is turned all the way up.
b. The music volume is changed to what appears to be 0.1 or just a sliver.
The questions this brings to mind is:
A. can I assign a value to the *cvar(s) in the onClick event? like
B. How can I check if the checkbox is checked or not? This did not seem to work:
C. How could I click another node from within an onClick event. For example user clicks on checkbox and I check if supposed to be at 0.0 or 0.5 volume based whether checked or not and then I click on the appropriate bar, for example the effects_bar, at the appropriate location(ie 0.0 or 0.5)?
D. If the user clicks on the bar how could I code the onClick event in the bar to check or uncheck the checkbox?
2. Is there a method of saving the original position of the sound prior to me hitting the checkbox to turn it off so that when I re-check the checkbox I can place it at the original position instead of the current positions of 1.0 and 0.1 or my proposed position 0.5?
So I checked out the documentation on the wiki and have more questions.
A user requested a modification and I wanted to see what it would entail to make a user modification for it. The request was to add checkboxes next to the effects_str and the music_str to turn them off and on similar to the checkbox sound_init node. He posted a pic here: http://ufoai.ninex.info/forum/index.php?topic=4428.msg33974#msg33974
I added the checkboxes and have obtained general functionality, but I am not satisfied with my results and have generated a few questions, which I find to be a positive thing as my primary interest is more in studying than making this work.
Code: [Select]
checkbox effects_box
{
current *cvar:snd_volume
pos "85 170"
size "20 18"
image "ui/checkbox_blue"
}
and Code: [Select]
checkbox music_box
{
current *cvar:snd_music_volume
pos "85 195"
size "20 18"
image "ui/checkbox_blue"
}
This works well enough in regards to setting the volume to 0.0 when it is unchecked.
However I run into a couple of various concerns and snags:
1. When I re-check the checkbox from an unchecked state, each of the volumes respond differently.
a. The effects volume is changed to 1.0 I would assume, ie. it is turned all the way up.
b. The music volume is changed to what appears to be 0.1 or just a sliver.
The questions this brings to mind is:
A. can I assign a value to the *cvar(s) in the onClick event? like
Code: [Select]
*cvar:snd_volume = 0.5
B. How can I check if the checkbox is checked or not? This did not seem to work:
Code: [Select]
onClick {if (*node:this@current < 1) { *cvar:snd_volume = 0.5}
if (*node:this@current > 0) { *cvar:snd_volume = 0.0}
}
C. How could I click another node from within an onClick event. For example user clicks on checkbox and I check if supposed to be at 0.0 or 0.5 volume based whether checked or not and then I click on the appropriate bar, for example the effects_bar, at the appropriate location(ie 0.0 or 0.5)?
D. If the user clicks on the bar how could I code the onClick event in the bar to check or uncheck the checkbox?
2. Is there a method of saving the original position of the sound prior to me hitting the checkbox to turn it off so that when I re-check the checkbox I can place it at the original position instead of the current positions of 1.0 and 0.1 or my proposed position 0.5?