cargo_import column in units.csv
Moderators: Omega, tillias, Mod Contributor
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
cargo_import column in units.csv
Hi everyone,
just a simple question:
What string/column/file determines whether the cargo_import given in units.csv works for a specific unit?
I had the idea to implement an ore harvesting option in PGG as it had already been discussed here in the forum. At first sight this seemed very easy to implement: adding the ore cargo to the cargo_import of an asteroid in units.csv and creating/implement the ore cargo to the game of course; maybe one hour of work alltogether. This way the ore should show up when the asteroid is destroyed; just like other cargo appears when a ship is destroyed.
Unfortunately it isn't that easy. No matter what I put to the cargo_import column of an asteroid it doesn't show up when the asteroid is destroyed. So there must be a switch somewhere that turns off this cargo_import functionality for specific units (as asteroids). Maybe it's the same that also switches off the targetability...
Hopefully someone can point me to the right direction.
Cheers,
Andy
just a simple question:
What string/column/file determines whether the cargo_import given in units.csv works for a specific unit?
I had the idea to implement an ore harvesting option in PGG as it had already been discussed here in the forum. At first sight this seemed very easy to implement: adding the ore cargo to the cargo_import of an asteroid in units.csv and creating/implement the ore cargo to the game of course; maybe one hour of work alltogether. This way the ore should show up when the asteroid is destroyed; just like other cargo appears when a ship is destroyed.
Unfortunately it isn't that easy. No matter what I put to the cargo_import column of an asteroid it doesn't show up when the asteroid is destroyed. So there must be a switch somewhere that turns off this cargo_import functionality for specific units (as asteroids). Maybe it's the same that also switches off the targetability...
Hopefully someone can point me to the right direction.
Cheers,
Andy
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: cargo_import column in units.csv
AFAIK, what appears when it explodes is what is in Cargo. If you put something in Cargo_Imports, you have to wait for some NPC to dock with it and "sell" it some ore, which might not happen either quick enough or at all without tweaks to trading.py
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
You are right about bases and the trading, but cargo_import is also used for the ships and what appears when they are destraoyed (at least in PGG). I also tried the cargo column... no luck...
btw: 'cargo_import' is column DB, 'cargo' is column DC in PGG...
btw: 'cargo_import' is column DB, 'cargo' is column DC in PGG...
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: cargo_import column in units.csv
If you modified the right unit, it should work. Which unit did you add the items to?
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
I found something in universe.py:
If I understand that correctly only ships and planets get cargo... (sorry, I've no clue on python code...)
Still the question remains how the engine 'knows' what a ship or a planet is....
Could these lines of code be modified to let all unit types get cargo?
Code: Select all
def systemCargoDemand (category,priceratio,quantratio,ships=1,planets=1):
i = VS.getUnitList()
un = i.current()
while (not un.isNull()):
if (un.isPlayerStarship()==-1):
isplanet = un.isPlanet()
if ( (isplanet and planets) or ((not isplanet) and ships)):
adjustUnitCargo(un,category,priceratio,quantratio)
i.advance()
un=i.current()
Still the question remains how the engine 'knows' what a ship or a planet is....
Could these lines of code be modified to let all unit types get cargo?
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: cargo_import column in units.csv
If you look carefully, "ships" means "not planets", so that would cover asteroids too. I think. You'd have to look for places where that function is called to see which parameters are sent.
Still... I don't think python scripts play a role here. Asteroid fields are created when loading the system file, in direct response to XML tags. That means python doesn't touch it, and "cargo_imports" then only affect what trading.py does later with the asteroid fields. But since asteroid fields aren't part of the dynamic universe dataset (AFAIK), then it's moot.
What matters then those ought to be "cargo", and what's there ought to be respected by the engine.
The trick, though, I think, is that units.csv has many entries for asteroids - there's the master "asteroid field" unit (not sure what its name is), that contains "asteroid group" subunits, which in turn contain a bunch of "asteroids". It's this last unit type the one you have to modify, identifiable because it won't have any subunits.
Except... except I found an interesting guard on the code preventing neutral units from dumping cargo. I guess that has to be fixed...
Still... I don't think python scripts play a role here. Asteroid fields are created when loading the system file, in direct response to XML tags. That means python doesn't touch it, and "cargo_imports" then only affect what trading.py does later with the asteroid fields. But since asteroid fields aren't part of the dynamic universe dataset (AFAIK), then it's moot.
What matters then those ought to be "cargo", and what's there ought to be respected by the engine.
The trick, though, I think, is that units.csv has many entries for asteroids - there's the master "asteroid field" unit (not sure what its name is), that contains "asteroid group" subunits, which in turn contain a bunch of "asteroids". It's this last unit type the one you have to modify, identifiable because it won't have any subunits.
Except... except I found an interesting guard on the code preventing neutral units from dumping cargo. I guess that has to be fixed...
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
I understand how the asteroid fiels work. I gave the 'cargo' only to the single asteroids not to the master asteroid field and the asteroid groups... but no luck so far.
Could you check that please? Maybe a workaround would be to set a fraction for the asteroids... Since they are passive it should make no difference whether they have a fraction or not...
Code: Select all
Except... except I found an interesting guard on the code preventing neutral units from dumping cargo. I guess that has to be fixed...
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: cargo_import column in units.csv
I'm thinking two options, one allowing asteroids to dump cargo, and one allowing neutral units to dump cargo.
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
BREAKTROUGH!!!
You gave the essential hint: the faction.
I changed the faction of the asteroid field in the system file to 'pirates'. Now it works. And btw, both columns in units.csv (cargo_import and cargo) work. Nonetheless I'll use cargo import: there you can define a certain probability for the ore to appear. That also works nicely for ships and adds more variation...
So no code tweaking neccessary. Thanks a lot!!!
You gave the essential hint: the faction.
I changed the faction of the asteroid field in the system file to 'pirates'. Now it works. And btw, both columns in units.csv (cargo_import and cargo) work. Nonetheless I'll use cargo import: there you can define a certain probability for the ore to appear. That also works nicely for ships and adds more variation...
So no code tweaking neccessary. Thanks a lot!!!
Last edited by Andy on Thu Feb 14, 2013 12:40 am, edited 1 time in total.
-
- The Shepherd
- Posts: 5841
- Joined: Fri May 13, 2005 8:37 pm
- Location: Ottawa
- Contact:
Re: cargo_import column in units.csv
Should that be faction not fraction darn English spelling never has been consistent.
Enjoy the Choice
Enjoy the Choice
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
Sorry, I was so excited... I correct it just in case somebody else reads it somewhen later...
-
- Merchant
- Posts: 32
- Joined: Tue Dec 04, 2012 7:52 pm
Re: cargo_import column in units.csv
Just to let you know: My idea of ore harvesting from asteroids works almost perfectly. The only problem that I have now is that sometimes ejected pilots appear when an asteroid is blown up... just like for blown up ships. I opened a new thread for this...
Thanks again for the help.
Thanks again for the help.
-
- Bounty Hunter
- Posts: 207
- Joined: Wed Oct 20, 2010 3:50 pm
- Location: Kungälv, Sweden
- Contact:
Re: cargo_import column in units.csv
Asteroidnauts!Andy wrote:The only problem that I have now is that sometimes ejected pilots appear when an asteroid is blown up... just like for blown up ships.
There are 10 types of people in this world, those who understand binary and those who don't.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: cargo_import column in units.csv
That's probably because the faction isn't the neutral faction.