Jump to content

[MOD] Turret Factory Seed Entry


Guest Alopix

Recommended Posts

Hi! This is the first time I've made a mod for a game!

 

I've been playing for a while, and digging around in the scripts messing with stuff. Today I was playing around with a turret factory. I noticed the seed didn't change, and I wondered why that was. Well, it's drawn from the station ID and your coordinates. I like the idea, it means you have an incentive to explore to find more factories, and remember where the good ones are!

 

But, what I really wanted at the time, was the ability to select the seed. Like you can at a shipyard. Lightbulb.

 

I opened /scripts/entity/merchants/shipyard.lua and found the bits governing the seed selection box, and crudely grafted them onto turretfactory.lua. A little bit of elbow grease and it worked.

 

With this mod, you can manually set the seed used to generate turret schematics at turret factories the same way you can when building a ship at a shipyard.

 

Place this file in /steam/steamapps/common/avorion/data/scripts/entity/merchants/. Or, I have made comments where I changed the code, if you have another mod using that file, you can graft these parts into the same places in your modded file.

 

I tested this on my own machine and it worked, but yours may have something different. Please let me know if it doesn't work for you, and I'll try to fix it. I have only the most basic programming knowledge and none specific to lua, so that may not happen...

 

This is a copy paste hack, I wrote nothing, all the code is Koonschi's.

 

https://drive.google.com/open?id=0B7YzN93iPgvcTFhSeURibXF6RGs

Link to comment
Share on other sites

For me, while the turret stats listed change, what is actually built remains based on the original turret factory seed.

 

Tested again and yep, it's broken. Sorry. The current version lets you change the seed, but the turret it actually gives you is the same no matter what.

 

I have a version now that lets you change the seed and actually get what you select, but it messes up the tech level and who knows what else, and I don't know why. I'll try to fix it in the morning.

Link to comment
Share on other sites

I really should have read the comments before installing this. Just bought 15 of what I thought was a REALLY good salvage laser, then ended up getting shit in comparison. =(

 

I'll eagerly await for the update that fixes this.

 

Great job though, it's kind of fun to be able to go through various seeds to see what kind of turrets there are.

Link to comment
Share on other sites

  • 2 weeks later...

I'm not that good with scripts but I think I figured out why the mod doesn't work as intended.

 

In the shipyard.lua, function setSeed includes argument updatePlan, which calls function updatePlan, which includes argument "local seed = seedTextBox.text", which becomes the actual seed to be used to create the ship. If I'm not mistaken.

 

Your mod has function setSeed, which includes argument refreshUI, which calls function refreshUI, so that's where you should add argument "local seed = something appropriate"

 

-edit-

 

Or, maybe you have to change function onSeedChanged because it still includes the argument "setSeed(seedTextBox.text)", which according to the rest of your mod is not the seed but +1/-1 to the seed. Something like:

 

"setSeed(same as argument "local seed = xxx" in function refreshUI)"

Link to comment
Share on other sites

I love the idea of this mod.... after two days of almost 18 hours I have finally collected enough stuff to make about 20-30 turrets and YOU KNOW WHAT I dont feel it to be the least bit "cheaty" considering how much time I put into the actual gathering of the parts. But yeah as it says in the comments.... :(

 

The mod shows you what the item would be but doesnt actually make them.

Link to comment
Share on other sites

  • 4 weeks later...

This mod essentially works

 

Things to watch out for...

 

it will make 0dps turrets if they seem to good and the sector tech level is low.

 

Experiment.

 

It does work but its trial and error.

 

I would love a more concise fix but for now its pretty cool.

Link to comment
Share on other sites

it will make 0dps turrets if they seem to good and the sector tech level is low.

Could you give me an example? Best would be a screenshot of a "too good to be true"-turret.

I would love a more concise fix but for now its pretty cool.

Well, I can't promise you anything, but I'll try.

Link to comment
Share on other sites

Although I didn't directly compare the 2 files for changes, I'm pretty sure laserzwei's fix works better. So if your going to mess with it try that.

 

The best thing to do is go into creative and give yourself the mats to experiment. Then you will see. I will try to upload a screen of what can happen if it goes badly.

 

here you go:

 

Screenshot70.jpg

 

Link to comment
Share on other sites

  • 3 months later...

Any possibility on this getting updated?

Tried to merge the codes into v12, the UI box for seed choosing showed up but had no actual effect on the end result.

Didn't learn anything about coding so I have no idea how to force it to use the chosen seed.

p.s.

Also the 0 dps turrets are probably result of the required materials didn't update to correct numbers.

From my experience it can be fixed by switching to different type and rarity of turrets.

Though final products were usually not exactly the same with the one in preview but at least they work.

Link to comment
Share on other sites

Here is a working version as of today (07/21/17)

 

http://dev-x.org/avorion/turretfactory.lua

 

 

I didn't have the original script, but thank you Alopix for pointing me to the files to get started

 

I've fixed the problem where you don't actually get the turret you see.

The script runs essentially twice, once on the server, and once on the client. Clicking the buttons updates the client, but the buildTurret function gets called on the server, so you need to pass the seed into that guy to update him as well.

 

This works in singleplayer, I do not know what may happen in multiplayer (another player may be able to change the seed of the factory your looking at, something like that).

 

As for the damage going below zero

That happens without mods. Being able to change the seed just makes it quicker to find.

 

The calculations for turret ingredients likely just go out of range, haven't looked at that yet. You can find seeds that have damage numbers that go up as you reduce the number of parts.

 

Note

I did change the default seeds, the seed number itself was way to large and didn't fit into the textbox

 

 

Anyway, enjoy!

 

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

0.15.1 changes turretfactory.lua significantly with the ability to set independent targeting, and adjusts DPS accordingly with various functions that weren't there before. I want to use custom seed with this new change. What specific changes do I need to do to make it work with the new .lua?

Link to comment
Share on other sites

Working version for 0.15.0, idkn does it work for 0.15.x versions.

 

Copied code from DevX's file to 0.15 file and edited to work with this version.

I also added line of code so you can make exotic rarity turret's.

(if you don't like possibility to build exotic turrets just delete 400th line of code rarityCombo:addEntry("Exotic"%_t))

 

I update it to 0.15 version, all credits go to original author.

 

HF

turretfactory.zip

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...