Search found 232 matches

by Therenas
Sat Feb 23, 2019 11:32 am
Forum: Modding help
Topic: style.horizontally_stretchable screwing things up?
Replies: 0
Views: 365

style.horizontally_stretchable screwing things up?

Hi there, I have a small GUI problem I would like to adress. It concerns scroll-panes, and I want the scrollbar (if it is visible) to always be as right in it's 'container' as it can be. The property 'horizontally_stretchable' on the scroll-pane seems to do this just fine, but I found that it screws...
by Therenas
Sat Feb 09, 2019 3:21 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

Alright, after several hours of trying to get this to work, I'm ready to move on. It has to be possible somehow, but it seems I'm not going to find out how for the moment. Thanks everyone for their help, though! Now, onwards to trying closure-based objects. Edit: Well, seems like that approach has k...
by Therenas
Fri Feb 08, 2019 10:49 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

No, they are not. I just need them to get reapplied on load to my classes. Just loading the file definition normally doesn't work when loading a save, I assume because then you recreate the classes, and the data you already saved has technically been saved with a different 'class' (different unique ...
by Therenas
Fri Feb 08, 2019 4:28 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

Yes, see doc-html/Data-Lifecycle.html in your install or at lua-api.factorio.com/latest. I read that, just wasn't 100% sure if I understood it correctly, thanks for confirming though. Another thing I just noticed in my testing, is that when I save the class (BaseClass for example) into the factorio...
by Therenas
Fri Feb 08, 2019 4:09 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

edit 2: see my edit of the original code, fixed Yeah I thought of namespace conflicts as well, should have tested that I guess. Fixing it prevents the crash, but sadly still doesn't have the intended effect. Thanks for your suggestions though, they made me understand the problem at hand much better...
by Therenas
Thu Feb 07, 2019 10:37 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

I haven't tested this, but I believe it'll work. Alright so I integrated this, and on world generation, it works, but when loading a save, the two lines in on_load() lead to a stack overflow for some reason. In the error report it says the overflow happens on the setmetatable(table,meta) call, insi...
by Therenas
Thu Feb 07, 2019 8:05 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

Re: How to persist classes

Thanks for the reply. I already store my objects in a global table. The issue I have, it seems, is with restoring the metatables correctly. How can I achieve that? Edit: The error I get, only when it is a loaded save, is that the functions of the class can not be found(= is nil). So I assume the met...
by Therenas
Thu Feb 07, 2019 12:02 pm
Forum: Modding help
Topic: How to persist classes
Replies: 12
Views: 2368

How to persist classes

I've been trying out classes in lua, including inheritance. My code looks like this: BaseClass = {} BaseClass.__index = BaseClass setmetatable(BaseClass, { __call = function (cls, ...) local self = setmetatable({}, cls) self:_init(...) return self end, }) function BaseClass:_init(name) self.name = n...
by Therenas
Mon Feb 04, 2019 10:48 am
Forum: Modding help
Topic: Migration help
Replies: 6
Views: 1279

Re: Migration help

As a side note, on_load() should only be called in very specific instances, otehrwise it leads to desync. Also, you can't use game.print() in the on_init() function, because on_init() is called before the world is fully loaded.
by Therenas
Sun Feb 03, 2019 11:41 pm
Forum: Modding help
Topic: Questions on GUI creation from a fresh modder
Replies: 7
Views: 2002

Re: Questions on GUI creation from a fresh modder

eduran wrote:
Sun Feb 03, 2019 7:17 pm
Thanks, especially for your answer to my second question. I overlooked that property.
No problem! I have given your first question some thought, and I might need something like that soon in a project I'm working on, so if I come up with anything, I will let you know.
by Therenas
Sun Feb 03, 2019 11:40 am
Forum: Modding help
Topic: Questions on GUI creation from a fresh modder
Replies: 7
Views: 2002

Re: Questions on GUI creation from a fresh modder

A few more: 1. Is it possible to make an entire row in a table clickable? Ideally, the row should be highlighted on mouseover. There is a table_with_selection style, but it doesn't actually allow any kind of selection. 2. Alternatively, is it possible to register clicks / mouseover through GuiEleme...
by Therenas
Sun Feb 03, 2019 11:31 am
Forum: Modding help
Topic: Shifting LuaGuiElements
Replies: 4
Views: 851

Re: Shifting LuaGuiElements

I assume you want to put an exit-button in the top right corner. Well you can get around the frame issue, by simply not settings a title, and doing it yourself, like this: local main_dialog = player.gui.center.add{type="frame", name="main_dialog", direction="vertical"} ...
by Therenas
Sun Feb 03, 2019 11:23 am
Forum: Modding interface requests
Topic: Ability to copy string to clipboard using api
Replies: 9
Views: 1957

Re: Ability to copy string to clipboard using api

Being able to do this without explicit user input is kinda risky, as it can lead to data loss. You can overwrite anything the user has in his clipboard, which could be something important. Sure it won't be the case very often, but the potential is there.
by Therenas
Sat Feb 02, 2019 10:46 pm
Forum: Modding help
Topic: Cheking if a file/sprite exists.
Replies: 5
Views: 1522

Re: Cheking if a file/sprite exists.

Klonan wrote:
Sat Feb 02, 2019 9:52 pm
You can use this function:
https://lua-api.factorio.com/latest/Lua ... prite_path
Oh wow, would not have thought to check the GUI class, even though it seems kinda obvious. Thanks a lot!
by Therenas
Sat Feb 02, 2019 9:23 pm
Forum: Modding help
Topic: Cheking if a file/sprite exists.
Replies: 5
Views: 1522

Re: Cheking if a file/sprite exists.

Hi, sorry to dig this up, but I have a problem that this would also solve. I'm working on a GUI-mod, and it displays item-sprites that the user can choose. Now if you add a modded one, and then remove that mod, I can no longer display it obviously. I would like to display a default image instead. No...
by Therenas
Wed Jan 30, 2019 1:22 pm
Forum: Modding help
Topic: Error catching?
Replies: 3
Views: 1003

Re: Error catching?

You don't want to ever catch an error unless it's something outside of your control (parsing user input for example). Catching errors in your logic just means you'll never hear about it being broken. If you have it crash-to-main-menu people are far more likely to tell you if they ever have an error...
by Therenas
Tue Jan 29, 2019 5:56 pm
Forum: Implemented mod requests
Topic: Allow enter-key for confirming dialogs
Replies: 11
Views: 3425

Re: Allow enter-key for confirming dialogs

Yeah I totally agree that in multi-line ones, enter should go to the next line. Implementing a shift-enter or ctrl-enter would be nice, but not as important, as those multi-line boxes aren't used for some quick input typically, thus aren't used as frequently, which makes enter not working less annoy...
by Therenas
Fri Jan 25, 2019 1:15 pm
Forum: Implemented mod requests
Topic: Add style.padding in the control stage
Replies: 1
Views: 923

Add style.padding in the control stage

I noticed that, when defining styles in the data stage, we can use the attribute padding to easily define all 4 padding-attributes (top, right, bottom, left) to the same value, at the same time. In the control stage however, this attribute is no longer available, and you have to 'manually' set all 4...
by Therenas
Wed Jan 23, 2019 11:09 am
Forum: Modding help
Topic: Error catching?
Replies: 3
Views: 1003

Error catching?

I'm currently working on an all-GUI mod, and I would love it if any errors that it produces would not crash the save. For development, crashing is fine of course, but when other people use my mod, I would feel better if they wouldn't lose unsaved progess on their game because of some error on my par...
by Therenas
Wed Jan 16, 2019 12:50 am
Forum: PyMods
Topic: pY Raw Ores Discussion
Replies: 1519
Views: 428878

Re: pY Raw Ores Discussion

the deeper you go down the chain usualy the ore/plate gets better Yes it does, and that is great, but I feel the additional effort is not worth it. Having to plonk down 180 machines and using 100MW of power seems worse than plopping down more miners to get the 4000 additional ore and having to expa...

Go to advanced search