Azerik Posted November 22, 2017 Share Posted November 22, 2017 I want some stations that just buy stuff, like casinos and the like. Anyone have a clue how to do that? I've looked at the merchants and it would seem I need a script more or less cloning one of the casino, biotope, or habitat.lua. I just can't figure out where those would be called from in order to have them created randomly. I've looked at consumer.lua but it doesn't seem to reference any of the merchant scripts. Link to comment Share on other sites More sharing options...
TKOed Posted November 22, 2017 Share Posted November 22, 2017 your best bet is to look at SectorGenerator.lua Link to comment Share on other sites More sharing options...
Azerik Posted November 22, 2017 Author Share Posted November 22, 2017 Well, taking a look at the sector generator did explain what consumer.lua is. It is what is loaded onto things like shipyards to make them buy stuff. My original idea was to have a Waste Incinerator that would buy up toxic waste and just get rid of it. I cloned the biotope.lua into... package.path = package.path .. ";data/scripts/entity/merchants/?.lua;" package.path = package.path .. ";data/scripts/lib/?.lua;" require ("stringutility") -- Don't remove or alter the following comment, it tells the game the namespace this script lives in. If you remove it, the script will break. -- namespace Incinerator Incinerator = require ("consumer") Incinerator.consumerName = "Incinerator"%_t Incinerator.consumerIcon = "data/textures/icons/pixel/scrapyard_fat.png" Incinerator.consumedGoods = {"Toxic Waste"} But I'm not sure if just having incinerator.lua in the merchants folder will be enough for the game to randomly make them or not. Link to comment Share on other sites More sharing options...
Hammelpilaw Posted November 23, 2017 Share Posted November 23, 2017 You also need to add it to sector generator to randomly generate it to npc sectors. You could also add it to stationfounder.lua to make it buildable for players. For our modpack I created a recycling factory that consumes toxic waste. For doing this you only have to modify productionsindex.lua. If you use the complex mod you can also add this factory into your complex (wich is not possible for a consumer). Link to comment Share on other sites More sharing options...
Azerik Posted November 25, 2017 Author Share Posted November 25, 2017 After running into this wall I did make a Waste Processor factory in productions index, but I still kinda wanted to go this route as well as I have some other ideas I'd like to implement this way. I'll go back through sectorgenerator and see if I can spot where this might be added, though I don't recall seeing anywhere in there for it before. Any idea where the consumers are in there? Thanks for putting up with my incessant questions. Link to comment Share on other sites More sharing options...
Hammelpilaw Posted November 25, 2017 Share Posted November 25, 2017 Oh sorry, my answer about SectorGenerator.lua was wrong. Did not have much time before going to work. In the folder /scripts/sectors are all types of sectors (every .lua file is one type of sector). If a sector may contain consumers, trading posts, turret factory and so on, they are created in the sectors generator script.F.e. in factoryfield.lua are turret- and fighterfactory created, and also resourcetrader: -- create a turret factory if math.random() < 0.33 then generator:createTurretFactory(faction) end if math.random() < 0.33 then generator:createFighterFactory(faction) end if math.random() < 0.5 then generator:createStation(faction, "merchants/resourcetrader.lua"); end This makes npc have a turret factory with a propability of 0.33 in such a sector. But when you add new stations to to productionsindex.lua, you do not need to add them anywhere else. The game automaticly creates factories from all stations in productionsindex.lua. If you have more questions feel free to ask. Link to comment Share on other sites More sharing options...
Azerik Posted November 30, 2017 Author Share Posted November 30, 2017 HA! Found it! data/scripts/sectors/loneconsumer.lua (only showing relevant snippet) -- create a consumer local consumerType = math.random(1, 5) if consumerType == 1 then generator:createStation(faction, "data/scripts/entity/merchants/casino.lua"); elseif consumerType == 2 then generator:createStation(faction, "data/scripts/entity/merchants/biotope.lua"); elseif consumerType == 3 then generator:createStation(faction, "data/scripts/entity/merchants/habitat.lua"); elseif consumerType == 4 then generator:createResearchStation(faction); elseif consumerType == 5 then generator:createMilitaryBase(faction) end Not being that familiar with lua, will changing that top line to be "math.random(1, 10)" generate a number from 1 to 10 instead of 1 to 5? Link to comment Share on other sites More sharing options...
Azerik Posted November 30, 2017 Author Share Posted November 30, 2017 I think I answered my own question. I modified the debug menu and added in my incinerator as an option, it worked! function onCreateConsumerButtonPressed() if onClient() then invokeServerFunction("onCreateConsumerButtonPressed") return end local generator = SectorGenerator(Sector():getCoordinates()) local faction = Galaxy():createRandomFaction(Sector():getCoordinates()) local station local consumerType = math.random(1, 4) if consumerType == 1 then station = generator:createStation(faction, "data/scripts/entity/merchants/casino.lua"); elseif consumerType == 2 then station = generator:createStation(faction, "data/scripts/entity/merchants/biotope.lua"); elseif consumerType == 3 then station = generator:createStation(faction, "data/scripts/entity/merchants/habitat.lua"); elseif consumerType == 4 then station = generator:createStation(faction, "data/scripts/entity/merchants/incinerator.lua"); end station.position = Matrix() Placer.resolveIntersections() end 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