From The Depths - Forum

Full Version: Custom turret Ids
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So, I'm still making my satelite and I ran into a bit of a problem that I don't think I can fix with LUA.
If you destroy the satelite's shield, the LUA doesn't really know how to handle it.

My problem is pretty much in the way the game handles weapon Ids.

Let's say we have 4 weapons:

Quote:Id: 4, Laser
Id: 3, Laser
Id: 2, Cannon
Id: 1, Turret

Now, if I destroy the Turret 1, the game just deletes the id, and after repairing the ship, the game adds the turrets Id after the other Ids, so what ends up happening is this:

Quote:Id: 4, Turret <--Repaired Turret 1
Id: 3, Laser
Id: 2, Laser
Id: 1, Cannon

As you can probably understand, this messes up any LUA based turret controls pretty easily.

So, a suggestion:
Option A: Make the game keep an Id on the turret from the blueprint, kind of like with the SubConstructs.
As far as I know, you can't use the SubConstructs to aim a turret, which is where my problem comes from. You can use it to aim a weapon, but not the actual turret.

Option B: Make it possible to create a custom Turret Id. This would fix the problem as well as making some pieces of code easier to understand when you don't have to memorize the Turret Ids.

[Image: attachment.php?aid=50485]
I cannot replicate this behavior.
Here is my test:
- add 2 turrets to the initial raft (Id 1 and 2)
- destroy turret Id 1
- wait for the avatar to repair the turret
- the turret Id is still 1
Note that I made some more tests to ensure that it also works with turrets on turrets.

In order to change a turret's Id you need to remove it, not destroy it.
The Id of a removed turret (or spinblock or piston) will never be used again for that blueprint.


As for the 'Custom Id', it will not be implemented because an Id is meant to be unique and it would be a pain to enforce it with names (especially knowing that you can copy/paste entire SubConstructs or prefabs).
But in the next release you will be able to set the names of the turret block (spinblock and piston block).
And hopefully access turret with it?
(2018-05-15, 07:15 AM)Fernir Wrote: [ -> ]And hopefully access turret with it?

As you say, hopefully.
It's not yet done but there's no reason it won't be in a near future.

For now I have done that so you can fully use the ACB 'pattern' feature.
But the idea is also to provide Lua functions to access turrets by name. And not only turrets, Mainframes also for example.
In fact, it should even be possible to control several blocks with the same name simultaneously (or using the same 'pattern' as the ACB).

The problem is what to do when you want to get information from a Mainframe using its name and that several mainframes do have the same name.
You can either return value for n-th object (null if it doesn't exist) or Id sorted array.
(2018-05-15, 06:52 AM)Gladyon Wrote: [ -> ]I cannot replicate this behavior.
Here is my test:
- add 2 turrets to the initial raft (Id 1 and 2)
- destroy turret Id 1
- wait for the avatar to repair the turret
- the turret Id is still 1
Note that I made some more tests to ensure that it also works with turrets on turrets.

In order to change a turret's Id you need to remove it, not destroy it.
The Id of a removed turret (or spinblock or piston) will never be used again for that blueprint.


As for the 'Custom Id', it will not be implemented because an Id is meant to be unique and it would be a pain to enforce it with names (especially knowing that you can copy/paste entire SubConstructs or prefabs).
But in the next release you will be able to set the names of the turret block (spinblock and piston block).

Sorry, I think I incorrectly said Weapon Id when I meant Weapon Index.
The game handles weapon indexes badly. My bad.

Anyways, I have written a simple LUA code to prove this behaviour:

Code:
T=0
function Update(I)
if(T<901) then
  if(I:GetWeaponInfo(T).Valid == true) then
  Weapon=I:GetWeaponInfo(T).WeaponType
  if(Weapon==0) then I:Log(T..", Cannon") end
  if(Weapon==1) then I:Log(T..", Missile") end
  if(Weapon==2) then I:Log(T..", Laser") end
  if(Weapon==3) then I:Log(T..", Harpoon") end
  if(Weapon==4) then I:Log(T..", Turret") end
  if(Weapon==5) then I:Log(T..", MissileControl") end
  if(Weapon==6) then I:Log(T..", FireControlComputer") end
  T=T+1
  end
end
end

Hopefully this clears some things up.
(2018-05-15, 01:46 PM)Juusoz Wrote: [ -> ]Sorry, I think I incorrectly said Weapon Id when I meant Weapon Index.
The game handles weapon indexes badly. My bad.

In the a future release I intend to fix most of that (maybe the next release).
I am implementing a real unique Id which is kept for the lifetime of the blueprint (as for the SubConstructs).

That new Id should be available for most types of blocks, so it should solve all the indexes problems for Lua.
Quote:In the a future release I intend to fix most of that (maybe the next release).
I am implementing a real unique Id which is kept for the lifetime of the blueprint (as for the SubConstructs).

That new Id should be available for most types of blocks, so it should solve all the indexes problems for Lua.

Thank you, it really would help alot.