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

Fix mechanic not being persistent #5306

Merged
merged 3 commits into from
Jan 10, 2022

Conversation

zonkmachine
Copy link
Member

@zonkmachine zonkmachine commented Nov 10, 2021

The 'Breakdown Servicing' character changes face in between chats. This is because Character.New() is called from the onChat function and somehow doing it with a persistent seed doesn't give persistent result. I don't know why that doesn't work. Instead I simplified the code a bit by generating the character on onCreateBB.

@impaktor
Copy link
Member

I'm guessing this might be related: #4810

@zonkmachine
Copy link
Member Author

I'm guessing this might be related: #4810

Yes. PR #4817 is mentioned in issue #4810 but it doesn't look done yet.
I'll look into the modules discussed in #4810.

@zonkmachine
Copy link
Member Author

zonkmachine commented Nov 10, 2021

@impaktor I've tested DonateToCranks and GoodsTrader and they are persistent. However, there is an intermittent problem with onCreateBB being rerun on bulletin boards that are already existing, described in #5305, and I think this is what's failing here. It's an intermittent issue so it may take some time to trigger it. At the time of #4810, #5305 would have behaved differently and I haven't seen onCreateBB being triggered on those earlier builds, but I think the core issue would have been the same/same-ish.
Edit: FuelClub also has a working persistency.

@zonkmachine
Copy link
Member Author

This PR is ready for review. For the other/similar issues mentioned above I believe they need more troubleshooting and most, if not all, depend on other issues.

@impaktor
Copy link
Member

Looking at the code, doesn't look like it will be persistent, i.e. same mechanic on same station always? I think that was the intention with the old code. Or are you using the local rand = Rand.New(station.seed + seedbump) anywhere?

@zonkmachine
Copy link
Member Author

Thanks!

Right, I don't actually know how to fly around in this game and it looks like I actually have to do that now. Will try it... :)

For the code I guess I have to go:

 local onCreateBB = function (station)
        local rand = Rand.New(station.seed + seedbump)
        local n = rand:Integer(1,#flavours)
-       local mechanic = Character.New()
+       local mechanic = Character.New({seed=rand:Integer()})

@sturnclaw sturnclaw merged commit c74ddc3 into pioneerspacesim:master Jan 10, 2022
@zonkmachine zonkmachine deleted the mechanic branch January 11, 2022 15:14
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

Successfully merging this pull request may close these issues.

3 participants