DarkPaapi Posted April 6, 2017 Share Posted April 6, 2017 Hello guys. The vanila game is not doing it so, I tring on a mod what changing the produced goods amouth on Player stations related to volume, like the NPC factories S, M, L, XL, XXL. Its might be look like and can be added into the facroy.lua --SCRAP-- - Get an timestep when the the program checking the size of the player own stations in the sector. function getUpdateInterval() return 120 --2 minutes for save performance end - When its updates checking the actual size of the stations and do the changes. function update(timeStep) -- Heres the part what i stucked with --- local station = Entity(xxx) -- need to call down the stations faction index local player = Player(xxx) -- need to call down the players faction index local maxNumProductions = factorySize + 1 -- number of the base producted goods what is 2 on size S local volume = station.getVolume -- get the volume of the station -- its starting from size S so dont need that one local scaleM = 6000 local scaleL = 12000 local scaleXL = 20000 local scaleXXL = 32000 for _, --station index-- in pairs(--player index--) do -- just do the changes on the player owned stations, realy not sure about it if scaleM < volume < scaleL than --size M maxNumProductions = maxNumProductions + 1 elseif scaleL < volume < scaleXL than --sizeL maxNumProductions = maxNumProductions + 2 elseif scalexL < volume < scaleXXL than -- sizeXL maxNumProductions = maxNumProductions + 3 elseif volume > scaleXL than -- sizeXXL maxNumProductions = maxNumProductions + 4 end end end The volume check is "could be good" because if something is taking down half of the station (ramming NPC) the production is falling back too. Im not sure my logic is good or not, but probably not... Just learning how to do magic... sorry about it. Link to comment Share on other sites More sharing options...
Laserzwei Posted April 6, 2017 Share Posted April 6, 2017 The biggest problem with changing the productionsize (internal name) is not the actual changing, but knowing when to change. Actively checking if a Block changed or registering events onBlockplanChanged/onBlockDestroyed are too resourcehungry atm. function getUpdateInterval() return 120 --2 minutes for save performance end This would also cause the productioncycle to take at least 2 minutes (currently 15seconds with 2 parallel cycles). Using Volume as a Balancer is a realy bad Idea. You can use Holographic or Stone blocks to very cheaply generate lots of Volume. Link to comment Share on other sites More sharing options...
DarkPaapi Posted April 6, 2017 Author Share Posted April 6, 2017 The biggest problem with changing the productionsize (internal name) is not the actual changing, but knowing when to change. Actively checking if a Block changed or registering events onBlockplanChanged/onBlockDestroyed are too resourcehungry atm. function getUpdateInterval() return 120 --2 minutes for save performance end This would also cause the productioncycle to take at least 2 minutes (currently 15seconds with 2 parallel cycles). Using Volume as a Balancer is a realy bad Idea. You can use Holographic or Stone blocks to very cheaply generate lots of Volume. Thank you very much Yes the first one is true, realy changeing the cycle, so its scrap The second one is true as well, it can be abused easely, but its still better than checking the actual change on blocks because of the performance isues just as you said. So its not that bad idea, the game is already using volume as a balancer in many ways. Link to comment Share on other sites More sharing options...
Thournicate Posted April 7, 2017 Share Posted April 7, 2017 Could you reduce any performance issues by tying it to a specific stat that is more difficult to game, say cargo space? Link to comment Share on other sites More sharing options...
Splutty Posted April 7, 2017 Share Posted April 7, 2017 The game actually does do this. Depending on the size of the station you will have more max production slots, so they will produce more. An XL station will run 4 productions (might be XXL), whereas an S station will only run 1. Link to comment Share on other sites More sharing options...
DarkPaapi Posted April 7, 2017 Author Share Posted April 7, 2017 The game actually does do this. Depending on the size of the station you will have more max production slots, so they will produce more. An XL station will run 4 productions (might be XXL), whereas an S station will only run 1. The game is not deciding the production amouth from size, its doing it in the opposive way. Looking up the sector and the surraunding sectors needs and give a production amouth for the station. Of course there is a random factor in it too. Name generator is looking for the amouth too, and than start to generate the volume, number of arms etc. This is why player stations are always geting the size S. its doesn't matter how big is the ship what was used as a foundation, or how big you build that station. Link to comment Share on other sites More sharing options...
Laserzwei Posted April 7, 2017 Share Posted April 7, 2017 The game is not deciding the production amouth from size, its doing it in the opposive way. Looking up the sector and the surraunding sectors needs and give a production amouth for the station. This is plain wrong. The initialize method in /entity/merchants/factory.lua determines which products and Factory size will be applied. The product (and its corresponding Productionprocess) are randomly selected between all goods that have a good.level within the sector-templates limits defined in /entity/merchants/(base-/low-/mid-/high-)factory.lua. The randomness is weightened so higher level goods are less common. The selection of base/low/mid/high is tied to the Galaxy-Seed. The Factory size is also determined by a wightened random selection, as well as its distance to the Core. From a distance of <450 to 300 the possible maximum size increases from 1 to 5. It has no further effect to the random selection. (...) This is why player stations are always geting the size S. Wrong agian. The factory size of a player-Factory is determined in entity/stationfounder.lua. Where in line 269-271 it says: -- make a factory station:addScript("data/scripts/entity/merchants/factory.lua", "nothing") station:invokeFunction("factory", "setProduction", production, 1) The 1 as the last parameter determines the size (1=S -> 5=XXL). its doesn't matter how big is the ship what was used as a foundation, or how big you build that station. That is correct, because noone ever bothered to implement it- also refer to my previous example. Link to comment Share on other sites More sharing options...
Splutty Posted April 7, 2017 Share Posted April 7, 2017 For completeness sake, this is the bit of code that Laser and I are talking about: function setProduction(production_in, size) factorySize = size or 1 maxNumProductions = 1 + factorySize maxNumProductions is used to determine the maximum amount of productions the factory can run at the same time, so it's completely dependent on the size of the factory. Try cloning an XXL Solar Power Plant, and you'll see what we mean. ps. How this ties in with your original question/suggestion: We just need to be able to make player stations different sizes! :) Link to comment Share on other sites More sharing options...
DarkPaapi Posted April 7, 2017 Author Share Posted April 7, 2017 Yes both of you are right, looked it up and its true, I was wrong its truly random and relying on probablity, apologies for it. Thats the part what was confused me: -- set title if station.title == "" then station.title = "Factory"%_t local size = "" if factorySize == 1 then size = "S /* Size, as in S, M, L, XL etc.*/"%_t elseif factorySize == 2 then size = "M /* Size, as in S, M, L, XL etc.*/"%_t elseif factorySize == 3 then size = "L /* Size, as in S, M, L, XL etc.*/"%_t elseif factorySize == 4 then size = "XL /* Size, as in S, M, L, XL etc.*/"%_t elseif factorySize == 5 then size = "XXL /* Size, as in S, M, L, XL etc.*/"%_t end local name, args = formatFactoryName(production, size) local station = Entity() station:setTitle(name, args) local arms = factorySize if string.match(production.factory, "Solar") then addSolarPanels(station, arms) end if string.match(production.factory, "Mine") then addAsteroid(station) end if string.match(production.factory, "Farm") or string.match(production.factory, "Ranch") then local x = 4 + math.floor(factorySize * 2.5) local y = 5 + factorySize * 4 addFarmingCenters(station, arms, x, y) end if string.match(production.factory, "Factory") or string.match(production.factory, "Manufacturer") or string.match(production.factory, "Extractor") then local x = 4 + math.floor(factorySize * 1.5) local y = 5 + factorySize * 2 addProductionCenters(station, arms, x, y) end if string.match(production.factory, "Collector") then addCollectors(station, arms) end end initializeTrading(bought, sold) end Since its giving the factory a title (S, M, L etc), and than if im right its expending the station after Goods type and factorySize. Edit: So the factorySize is random, maxNumProductions is random to since production = {} maxNumProductions = 2 ... maxNumProductions = data.maxNumProductions factorySize = data.maxNumProductions - 1 Try cloning an XXL Solar Power Plant, and you'll see what we mean. I tried it. If you cloning something in the game is cloning everyting, included the random numbers too so it will be execly the same. Excep if its not contains the math.randomseed(seed) part. I find that one out when i created a modul and every time i loaded the save it have different stats. But back to the point, heres the problem what Lazerwei mentioned befor, i cant go after the volume becouse its abusable with stone and hologram. If i going after the size what are pregenerated elements, its need to be execly the same and could be highly performance hungry. So probably just one way left, try to ask for a certain BlockType Volume inside an Entity. I think i seen them in the documentation. Edit : For Power Plant it shoud be easier because need to look up for the produced energy amouth, it can be generator or solar panel doesnt matter i think. Link to comment Share on other sites More sharing options...
DarkPaapi Posted April 7, 2017 Author Share Posted April 7, 2017 We just need to be able to make player stations different sizes! Yes thats one way, the first one what is come to my mind too, but i like to build and dont see point to buy another station just because i want more production :) its like buying a new computer in every year because its a bit faster :D I dont need Mac thank you... Edit: I was wrong again, its prety good idea. Create an option to upgrade the existing ones for money and goods. To do this just need to create one more option in the interaction window, or in the stations UI... Edit 2: But for that you don't need to rise the size/volume neither... Edit 3: expect if you can make a check on the entities plan is it contains a certain template (like the pre-generated solar panel what already have one) and instead of time step its event triggered, its limits creativity but saving performance.... And its still can be tricked like building up the station, upgrade, and than deconstruct the extra, ending up with a 1 x 1 x 1 cube of XXL factory Link to comment Share on other sites More sharing options...
DarkPaapi Posted April 12, 2017 Author Share Posted April 12, 2017 Laserzwei is just released his station complex mod (what is amazing) but i want to go with this one as well for single stations. Since he was much further ahead with the idea of useing the power as constans for production, i dont want to go to the same direction. So i going along with volume. Made some observation on the game mechanism. For my test i created a ship, give it a name (what i can remember for 10 secunds), jumped into build mode and make a save. Alt-Tab and took a look into the games saved ships. Opened up the file what just have been made. <?xml version="1.0" encoding="utf-8"?> <auto_2682239530652318457 accumulateHealth="true" convex="false"> <item parent="-1" index="0" maxDurability="32" currentDurability="32"> <block lowerX="-1" lowerY="-1" lowerZ="-1" upperX="1" upperY="1" upperZ="1" index="1" material="0" look="1" up="3" color="ffbfaea3"/> </item> </auto_2682239530652318457> Than go back inside and changed the block iron hull to iron engine, than save. <?xml version="1.0" encoding="utf-8"?> <auto_2682658513304140150 accumulateHealth="true" convex="false"> <item parent="-1" index="0" maxDurability="16" currentDurability="16"> <block lowerX="-1" lowerY="-1" lowerZ="-1" upperX="1" upperY="1" upperZ="1" index="3" material="0" look="1" up="3" color="bfbfbfbf"/> </item> </auto_2682658513304140150> The differences between the two is the auto_xxx what could be the saved template index, color what i dont realy care and there is the index for the block. I did the change a few more times and the index number is always different so that one is controls what type of block it is (Hull, engine, generator, shield etc) And theres the lowerX,Y,Z and upperX,Y,Z wich ones are coordinates from the ship center point. So if i want to get a certen block type volume or surface area in a contruction, what i need to do is do some math. upperX - lowerX give me the x side of the cube of coure if the coorinates are off from the main 0 point i need to do a criteria to never be negative. And its looks like if x < 0 than x = x * (-1) so it will be always a positive number. Doing the same with Y and Z. and than X * Y * Z = Volume, for surface 2 * ((X * Y) + (X * Z) + (Y * Z)) = Surface. So i have a certean block type Volume and Surface area inside a contruction. My questsion is, is it posible to make a script what can take out certean information from the xml plan file, do the math. Than compare them whit a given stats and when the threthold is meet for example the Entity is contains V volume of I index of block, rise the value. If yes it could be way to add production amouth if a certean volume of specified block contanied by the Entity. And display it in UI Of course it need to make it triggered when the plan is saved. Down side if blocks getting destroyed its not updating the input. Maybe the base probram is useing something similar to add stats for an entity. But do it real time. If entity contains this block whith that blockindex, than "addMultiplyableBias(StatsBonuses.ArbitraryTurrets, Volume)" the turrets just an example. But dont know just guessing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now