Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scenario issue] Training: Cruiser DB link hs with some non-existent ships #1686

Open
muerteFR opened this issue Feb 9, 2022 · 4 comments
Open

Comments

@muerteFR
Copy link
Contributor

muerteFR commented Feb 9, 2022

I don't know if we can put here problems concerning scenarios.
The link to the DB for some ships doesn't work. Like "Exuari freighter", "Exuari transport", "Exuari Shuttle"... even in EN language.
Which seems logical since these ships do not/no longer exist in the DB.

@muerteFR
Copy link
Contributor Author

muerteFR commented Nov 6, 2022

Hi @Piglit I I believe you created this scenario, I raise this problem. Could you fix it?

@oznogon
Copy link
Contributor

oznogon commented Jan 19, 2023

This isn't trivial because of how ships are added to the Science database and linked to from the Science radar, and it's hard to pin this on @Piglit or any scenario writer because the tools aren't there to do this easily.

Today, EE populates the Ships database on scenario launch by parsing ShipTemplates from files in scripts/shiptemplates. The Exuari ships that don't show up in the database aren't in shiptemplates files or ShipTemplate objects, but are standard ships created with a custom type name by using ShipTemplateBasedObject:setTypeName():

function createExuariTransport()
	return CpuShip():setFaction("Exuari"):setTemplate("Personnel Freighter 1"):setTypeName("Exuari transport")
end

Doing this breaks the DB link to Personnel Freighter 1, because that link relies on a string comparison of the type name. (#1271) But aside from that, we probably want new entries for the new ships anyway.

To minimally "fix" this, the scenario can create entries for those ship types in the Science database:

-- Get the Exuari Ships ScienceDatabase object
exuari_ship_db = queryScienceDatabase("Ships","Exuari")
-- Add the entry
exuari_transport = exuari_ship_db:addEntry(_("Exuari transport"))
-- Put something in it
exuari_transport:setLongDescription(_("Exuari transport description goes here"))

To copy the base ship template's full data also in that new db entry, you need a Lua function that duplicates as much of an existing ScienceDatabase under a new name as it can:

function copyShipDBEntry(base_ship_template,new_ship)
  ship_db = queryScienceDatabase("Ships")

  -- Search each Ships class's entry for the base ship
  for k,entry in ipairs(ship_db:getEntries())
  do
    base_ship_entry = entry:getEntryByName(base_ship_template)
    if base_ship_entry ~= nil
    then
      break;
    end
  end

  -- Create a new Exuari DB entry for the new ship
  exuari_ship_db = ship_db:getEntryByName("Exuari")
  new_ship_entry = exuari_ship_db:addEntry(new_ship:getTypeName())

  -- Copy base ship data to the new entry
  for k,v in pairs(base_ship_entry:getKeyValues())
  do
    new_ship_entry:setKeyValue(k,v)
  end

  new_ship_entry:setImage(base_ship_entry:getImage())
  -- Impossible without a getModelName() function
  -- new_ship_entry:setModelName(base_ship_entry:getModelName())

  return new_ship_entry
end

Then invoke it and patch up what's specific to the new ship, and manually add the data that scripts can't copy. We can't pull data from ShipTemplates, so we have to spawn a new ship that uses the template.

So for Exuari freighters:

function createExuariFreighter()
	return CpuShip():setFaction("Exuari"):setTemplate("Goods Freighter 5"):setTypeName("Exuari freighter")
end

You could add something like:

-- Create a dummy ship to use for populating the entry
init_transport = createExuariFreighter()
-- Call our copy function
-- We can't get the template from the ship, so we have to pass it manually
init_transport_entry = copyShipDBEntry("Goods Freighter 5", init_transport)
-- Set the description to something unique
init_transport_entry:setLongDescription(_("The Exuari freighter freights Exuari"))
-- Manually set the model data since we can't get it from the ship nor the entry
-- This requires finding the shiptemplate file and copying and pasting its model
init_transport_entry:setModelDataName("transport_2_5")
-- Immediately destroy the dummy ship
init_transport:destroy()

Which results in this when clicking the DB button on any Exuari freighter, since the string lookup now works:

image

No idea if this is enough to satisfy translation requirements, and it's a large number of hoops to jump through for a scenario to paper over how the link feature works, and to copy ship content that mostly already exists.

  • A convenience feature to copy a ScienceDatabase entry to a new name and parent would help, whether as a built-in scripting function or added to utils.lua.
  • A ScienceDatabase:getModelDataName() scripting function seems to be missing.
  • Simply not showing the DB button on Science radar if there's no corresponding ScienceDatabase entry would avoid confusion.

But something like #1271 would solve the deeper problem of addressing DB entries and links, especially for this use case:

It allows ships to have different database entries per type, which could be used to give histories of named ships. ... It also allows multiple ships to point to the same database entry which seems more useful.

oznogon added a commit to oznogon/EmptyEpsilon that referenced this issue Jan 19, 2023
Exuari transports, freighters, and shuttles use custom ship type
names, which breaks DB links from the Science radar. (daid#1686)

Work around this by adding a function that copies the base ship
template's data to a new entry with the same ship type name.
oznogon added a commit to oznogon/EmptyEpsilon that referenced this issue Mar 19, 2023
Exuari transports, freighters, and shuttles use custom ship type
names, which breaks DB links from the Science radar. (daid#1686)

Work around this by adding a function that copies the base ship
template's data to a new entry with the same ship type name.
daid pushed a commit that referenced this issue Apr 12, 2023
Exuari transports, freighters, and shuttles use custom ship type
names, which breaks DB links from the Science radar. (#1686)

Work around this by adding a function that copies the base ship
template's data to a new entry with the same ship type name.
@muerteFR
Copy link
Contributor Author

muerteFR commented Aug 4, 2023

This problem is still present.

  1. There is an additional error that is displayed compared to a few months ago (cf picture)
  2. Note that in the description, it is indicated that our ship is the Phobos whereas since an update, this is no longer the case. You can choose any ship.
    training

@muerteFR
Copy link
Contributor Author

This scenario no longer works at all in the Fr translated version. The incoming call doesnt appear and only 1 enemy ship appears in the same place as us.

Tsht pushed a commit to Tsht/EmptyEpsilon that referenced this issue Nov 22, 2023
Exuari transports, freighters, and shuttles use custom ship type
names, which breaks DB links from the Science radar. (daid#1686)

Work around this by adding a function that copies the base ship
template's data to a new entry with the same ship type name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants