Nexus Modding > Scripting
Scripting Issues
Arparso:
--- Quote ---@Arparso: Why did you use the E.EnginesCount variable? Isn't it enough by using the E.engines list?
-- Just corrected myself: it's more efficient to check a variable that use walk trough a list... that's why you used enginesCount, right?
--- End quote ---
Exactly. SelectDevices() already returns the number of selected devices, so a call to AllNumOf() isn't required anymore. I wouldn't expect a performance difference between both variants, although it's hard to tell without knowing how these functions are implemented. Unless you're calling AllNumOf() a few thousand times per frame, you probably shouldn't even care.
The Old Dragon:
Question:
How can I get the top speed of a ship on normal burn?
obj:tGetVelocity(); only reports the current speed (not helpfull as I know the speed at this point will be zero);
obj:tGetMaxVelocity(); gives the engines top possible speed when on full burn( again, not usefull as this speed exceeds the limit I'm trying to set).
The idea is to limit a formation leaders top speed slightly so that any other ship of the same class/type as the leader can take it's place in a formation instead of lagging behind.
Oh, and I can't look at the tacticstypes.ini for this info as the script is for any and all ships.
Arparso:
--- Quote ---How can I get the top speed of a ship on normal burn?
--- End quote ---
I don't know of a script command or variable to directly get the normal speed, but it can be calculated. tGetMaxVelocity() gets you the highest achievable speed when routing additional energy into the engine subsystem. This is 50% more than the ship's regular speed, so the regular speed can be calculated by multiplying the maximum velocity with 2/3.
There's one caveat to that: probably every engine has both a setting for EnergyIn and EnergyOutput. The first dictates how much energy the engine uses each tick when being fully active (at regular speed) and the second setting specifies the amount of energy the engine itself generates each tick. If both values are equal, the engine can operate at regular speed (100%) without needing any additional energy and achieves up to 150% speed when being fed with support energy.
If EnergyOutput is actually higher than EnergyIn, the engine will actually exceed the regular speed without needing additional energy, but will still be limited to a maximum of 150% of the regular speed. Using the above calculation, however, gets you the regular speed, but not the actual speed the engine is really capable of.
The other way around is even worse: if EnergyOutput is lower than EnergyIn, the engine will not be able to reach the regular speed without any additional support energy. It also won't get to the usual 150% speed level, even if being fed enough support energy. tGetMaxVelocity() will NOT account for that (nor will the GUI) and will still report the theoretical 150% speed, even though the engine operates below that level. This leaves you with a calculated regular speed way above the actual engine's capabilities.
I don't know a good way to get around these two cases. Especially the second one is pretty bad as you'll calculate a speed way too fast for your engine while in the first case you'll just slow down your ship a bit, which alone would be tolerable. That being said, I'd consider it bad practice to actually include such an engine in your mod (with EnergyOutput being lower than EnergyIn), as it also screws up the manual speed panel on the GUI. Avoiding that, the simple calculation above should be sufficient for most needs.
The Old Dragon:
Thanks Arparso, that works just fine.
Got another quick question that's making me go ggrrrr.
Using the 'Detected' rule, how do I find out which ship is doing the detecting?
Arparso:
Now that's a good question... I have absolutely no idea and I don't even see any helpful scripting command or variable.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version