[SCRIPT] Hear you ship engines in cockpit
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
[SCRIPT] Hear you ship engines in cockpit
Thanks to X2-Illuminatus for helping (by helping I mean completely doing it lol) me!
I just started playing X3 AP after some Rebirth, and one thing that is really missing for me in X3 is the sound of the engine in cockpit. This simple script let you bind a hotkey called "Engine Sound" to activate or deactivate the background engine sound!
Install : Use plugin manager or extract content to addon\script folder.
Use : Register hotckey under "Controls, Interface"
Activate engine sound to your will.
The script can be modified to suit your taste by changing the sound ID and Miliseconds value of the loop in the XML file. The complete list of sounds can be found there :
http://forum.egosoft.com/viewtopic.php?t=287352
Enjoy! You can ignore the rest of this post as it is only there for history!
DOWNLOAD (Link posted by X2-Illuminatus, thanks again!)
http://www.mediafire.com/download/r96wv ... hotkey.zip
______________________________________________________________________
INITIAL POST : Hey guys. I'm trying to make a basic scrip that will go as follow and I need your help. I'm an IT guy and really good with computers, but I'm not really good at programming.
I'm willing to make a script that will go as follow :
1-Press a key to activate the script
2-The script will play a sound and LOOP as long as the key is not pressed again
3-Press the same key (or a different one) to end the script
I already know the sound ID that want to use, it will be 952.
The goal of that script would be to activate engine sounds while in cockpit mod! It will add a lot to immersion I believe.
I thank you a lot for your help!
EDIT : Ok 27 views and no reply. I really want to get this working, I am willing to give a Steam gift card of 20$ to whoever could help me. I know how to use the "play sound" command, I just want to have the script loop until it is deactivated. I'm sure it can be done really easily.
Regards,
___________________________________________________________________[/url]
I just started playing X3 AP after some Rebirth, and one thing that is really missing for me in X3 is the sound of the engine in cockpit. This simple script let you bind a hotkey called "Engine Sound" to activate or deactivate the background engine sound!
Install : Use plugin manager or extract content to addon\script folder.
Use : Register hotckey under "Controls, Interface"
Activate engine sound to your will.
The script can be modified to suit your taste by changing the sound ID and Miliseconds value of the loop in the XML file. The complete list of sounds can be found there :
http://forum.egosoft.com/viewtopic.php?t=287352
Enjoy! You can ignore the rest of this post as it is only there for history!
DOWNLOAD (Link posted by X2-Illuminatus, thanks again!)
http://www.mediafire.com/download/r96wv ... hotkey.zip
______________________________________________________________________
INITIAL POST : Hey guys. I'm trying to make a basic scrip that will go as follow and I need your help. I'm an IT guy and really good with computers, but I'm not really good at programming.
I'm willing to make a script that will go as follow :
1-Press a key to activate the script
2-The script will play a sound and LOOP as long as the key is not pressed again
3-Press the same key (or a different one) to end the script
I already know the sound ID that want to use, it will be 952.
The goal of that script would be to activate engine sounds while in cockpit mod! It will add a lot to immersion I believe.
I thank you a lot for your help!
EDIT : Ok 27 views and no reply. I really want to get this working, I am willing to give a Steam gift card of 20$ to whoever could help me. I know how to use the "play sound" command, I just want to have the script loop until it is deactivated. I'm sure it can be done really easily.
Regards,
___________________________________________________________________[/url]
Last edited by Violins77 on Mon, 27. Oct 14, 20:19, edited 6 times in total.
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24961
- Joined: Sun, 2. Apr 06, 16:38
A really basic script (a.engine.sound.xml) for playing a certain sound id, activated by a hotkey:
And the respective setup script (setup.engine.sound.xml):
Both can be downloaded here (mediafire.com).
The setup script is executed on every game start / game load of a modified game. It checks if a global variable ('globvar.engine.sound.setup') is set. If not, it will register a hotkey and saves the return value of the register hotkey command to the first global variable. That way the hotkey is only registered once and you can use the return value to unregister the hotkey later. When that has been done, you can bind a key to the "Engine sound" hotkey in the game options under Controls -> Interface -> Extensions. Please note that hotkeys only work when being in space (i.e. when you're not docked to a station).
The hotkey starts the (globally running) script a.engine.sound.xml, which checks for a second global variable ('globvar.engine.sound'). If it doesn't exist (i.e. the get global variable commands returns null), it will set this variable to 1. As long as this is case, the following while-loop is executed, which plays the sample with the id 952 and waits then 3.8 seconds* before playing the sample again (and so on). When you press the hotkey a second time, the a.engine.sound.xml will be started a second time. Now, however, it notices that the global variable ('globvar.engine.sound') exists and sets it to null. Both started a.engine.sound.xml scripts will end then. The second one, because there is no further action defined, and the first started one, because the while statement of the loop is no longer true.
All commands used in these two script files, except for the play sample command (Audio commands), can be found in the General commands section. Loops and conditional statements can be created using the <RetVar/IF><Expression> command. 'else' and 'end' statements can be selected from the Flow Control section of the General commands.
Both scripts can certainly be improved, but they should give you an idea on how a basic script looks like and works.
*(You may need to adjust this slightly to find the perfect duration for the sample to be repeated.)
Code: Select all
001 $globvar.name='globvar.engine.sound'
002 ifget global variable: name=$globvar.name
003 |set global variable: name=$globvar.name value=null
004 else
005 |set global variable: name=$globvar.name value=1
006 |whileget global variable: name=$globvar.name
007 ||play sample 952
008 @ ||$wait=wait 3800 ms
009 |end
010 end
011 return null
Code: Select all
001 if notget global variable: name='globvar.engine.sound.setup'
002 |$hotkey=register hotkey 'Engine sound' to call script 'a.engine.sound'
003 |set global variable: name='globvar.engine.sound.setup' value=$hotkey
004 end
005 return null
The setup script is executed on every game start / game load of a modified game. It checks if a global variable ('globvar.engine.sound.setup') is set. If not, it will register a hotkey and saves the return value of the register hotkey command to the first global variable. That way the hotkey is only registered once and you can use the return value to unregister the hotkey later. When that has been done, you can bind a key to the "Engine sound" hotkey in the game options under Controls -> Interface -> Extensions. Please note that hotkeys only work when being in space (i.e. when you're not docked to a station).
The hotkey starts the (globally running) script a.engine.sound.xml, which checks for a second global variable ('globvar.engine.sound'). If it doesn't exist (i.e. the get global variable commands returns null), it will set this variable to 1. As long as this is case, the following while-loop is executed, which plays the sample with the id 952 and waits then 3.8 seconds* before playing the sample again (and so on). When you press the hotkey a second time, the a.engine.sound.xml will be started a second time. Now, however, it notices that the global variable ('globvar.engine.sound') exists and sets it to null. Both started a.engine.sound.xml scripts will end then. The second one, because there is no further action defined, and the first started one, because the while statement of the loop is no longer true.
All commands used in these two script files, except for the play sample command (Audio commands), can be found in the General commands section. Loops and conditional statements can be created using the <RetVar/IF><Expression> command. 'else' and 'end' statements can be selected from the Flow Control section of the General commands.
Both scripts can certainly be improved, but they should give you an idea on how a basic script looks like and works.
*(You may need to adjust this slightly to find the perfect duration for the sample to be repeated.)
There's really no need to offer any (money) rewards. People on these forums are usually very helpful. However, you posted in the very early morning hours for most Europeans on a Sunday. In addition, X3TC and X3AP are already several years old, so these forums are not the most active ones anymore, which naturally results in longer waiting times before someone answers.Violins77 wrote:EDIT : Ok 27 views and no reply. I really want to get this working, I am willing to give a Steam gift card of 20$ to whoever could help me.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
Also, I will tweak it and experience it with different sound ID and MS value as you said. There is no way I would have known how to do all this without your help. Now it's only a matter of editing the XML for me. I will modified the thread title and post it as a new script when ready (and obviously credit you totally for it)! Are you guys software engineers?
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24961
- Joined: Sun, 2. Apr 06, 16:38
No need, but thanks anyway. I'm glad that it works as expected.Violins77 wrote:Just PM me your Steam account if you want the reward still, a promise is a promise!
I'm an engineer, not one for software though. Nevertheless, I do have some experience in programming and writing (MSCI) scripts for the X games.Violins77 wrote:Are you guys software engineers?
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!