Search found 127 matches

by sdgmlj
Mon Aug 01, 2022 3:52 pm
Forum: Modding help
Topic: How to read the file contents in the user data folder
Replies: 5
Views: 133

Re: How to read the file contents in the user data folder

Thank you for your reply. My idea is like this. I want to save the content of "quickbar" to a file so that it can be automatically read when I start a new game next time. So my idea can't be realized? Is that so? Yes, you are correct that it cannot be realized in that form. There are alte...
by sdgmlj
Mon Aug 01, 2022 10:40 am
Forum: Modding help
Topic: How to read the file contents in the user data folder
Replies: 5
Views: 133

Re: How to read the file contents in the user data folder

There is no such thing as "read a file". When a script is running in a multiplayer game, every instance of the game would be trying to read the same file from different machine and if the content would be different a desync would happen. Primary way of mutable data storage is through a va...
by sdgmlj
Mon Aug 01, 2022 9:41 am
Forum: Modding help
Topic: How to read the file contents in the user data folder
Replies: 5
Views: 133

Re: How to read the file contents in the user data folder

No one to help? I really need this answer
by sdgmlj
Mon Aug 01, 2022 5:11 am
Forum: Modding help
Topic: How to read the file contents in the user data folder
Replies: 5
Views: 133

How to read the file contents in the user data folder

I saved one of my forms in the "script output" folder. The official wiki only said how to write it, but I didn't find out how to read it local quickbar = {.........} local text = game.table_to_json(quickbar) game.write_file("save/quick-bar.json",text) What command do I use to rea...
by sdgmlj
Sat Jun 18, 2022 11:52 am
Forum: Modding help
Topic: How do I call the vanilla tooltip?
Replies: 3
Views: 334

How do I call the vanilla tooltip?

I want to display it on "Sprite button". I don't want to use "choose elem button" because it doesn't allow "number" to be displayed. How should I write it? tooltip = ???

Thank you
by sdgmlj
Thu Jun 16, 2022 11:33 am
Forum: Modding help
Topic: Can I modify the character's backpack GUI?
Replies: 0
Views: 239

Can I modify the character's backpack GUI?

I want to add a button on it. At present, I have added a "relative" GUI. I want to move to the top of the backpack through coordinate offset, but it will be blocked by the backpack. It seems that the system GUI will be displayed on the top layer. Is there a way to solve it?
by sdgmlj
Mon Jun 13, 2022 2:30 pm
Forum: Modding help
Topic: About the parameter "Don show but allow monitoring"
Replies: 0
Views: 232

About the parameter "Don show but allow monitoring"

This is a parameter of "luaguielement scroll pane". The official gives five choices: "never" "always" "auto and reserve space" "Don show but allow scrolling" "auto" My understanding of "Don show but allow scrolling" is that the sl...
by sdgmlj
Sun Jun 12, 2022 11:26 pm
Forum: Modding help
Topic: How can I filter this article
Replies: 2
Views: 253

Re: How can I filter this article

DaveMcW wrote: ↑
Sun Jun 12, 2022 4:30 pm

Code: Select all

for _, fluid in pairs(game.fluid_prototypes) do
  if not fluid.hidden then
    game.print(fluid.name)
  end
end
Thank you, that's right
by sdgmlj
Sun Jun 12, 2022 12:01 pm
Forum: Modding help
Topic: How can I filter this article
Replies: 2
Views: 253

How can I filter this article

When I use "game.fluid_prototypes" to search all fluids, this item appears. I don't want it to be displayed. How do I filter it?

type=??
name=??
by sdgmlj
Fri Jun 10, 2022 11:05 am
Forum: Modding help
Topic: Can you help me see what's wrong with it?
Replies: 7
Views: 432

Re: Can you help me see what's wrong with it?

First of all, thank you very much for your help. I will change the content to: for c,_ in pairs(e.crafting_categories) do It still reports an error with the content "bad argument \1 of 2 to'pairs'(table expected, got Nil)" Then you have to check that e.crafting_categories is not nil if e....
by sdgmlj
Fri Jun 10, 2022 10:54 am
Forum: Modding help
Topic: Can you help me see what's wrong with it?
Replies: 7
Views: 432

Re: Can you help me see what's wrong with it?

local g = game.recipe_prototypes[item_name] for _,e in pairs(game.entity_prototypes) do for _,c in pairs(e.crafting_categories) do if c == g.category then 。。。。。。。。 end end end I want to find out all the production machines of this formula, but it always reports errors. Where is the error? Thank you...
by sdgmlj
Fri Jun 10, 2022 10:52 am
Forum: Modding help
Topic: Can you help me see what's wrong with it?
Replies: 7
Views: 432

Re: Can you help me see what's wrong with it?

First of all, thank you very much for your help. I will change the content to:

for c,_ in pairs(e.crafting_categories) do

It still reports an error with the content "bad argument \1 of 2 to'pairs'(table expected, got Nil)"
by sdgmlj
Fri Jun 10, 2022 6:39 am
Forum: Modding help
Topic: Can you help me see what's wrong with it?
Replies: 7
Views: 432

Can you help me see what's wrong with it?

local g = game.recipe_prototypes[item_name] for _,e in pairs(game.entity_prototypes) do for _,c in pairs(e.crafting_categories) do if c == g.category then 。。。。。。。。 end end end I want to find out all the production machines of this formula, but it always reports errors. Where is the error? Thank you
by sdgmlj
Sun Jun 05, 2022 11:44 am
Forum: Modding help
Topic: I want to modify the content of function in another mod in my mod. Is there any way?
Replies: 5
Views: 496

Re: I want to modify the content of function in another mod in my mod. Is there any way?

To put it simply, I want to modify the content of function in another mod. For example, the name is ABCDE (). Is there any way to modify it in my mod?
by sdgmlj
Sun Jun 05, 2022 11:39 am
Forum: Modding help
Topic: I want to modify the content of function in another mod in my mod. Is there any way?
Replies: 5
Views: 496

I want to modify the content of function in another mod in my mod. Is there any way?

His function is called by "control.lua". I only make small changes to apply to my mod, not destructive changes, and will not affect his mod. Is there any way?
by sdgmlj
Mon May 23, 2022 3:41 am
Forum: Modding help
Topic: How can I get the "index" of the current character in "script. On_init"
Replies: 4
Views: 417

Re: How can I get the "index" of the current character in "script. On_init"

The mod doesn't know whose computer it is running on--it runs on everyone's simultaneously. There is no "me", there is only player 1, player 2, etc. The mod can receive events every time any player does something like open a GUI or press a key, with a link to the player that did it. There...
by sdgmlj
Mon May 23, 2022 2:56 am
Forum: Modding help
Topic: How can I get the "index" of the current character in "script. On_init"
Replies: 4
Views: 417

Re: How can I get the "index" of the current character in "script. On_init"

Mod scripts run at the game level, and execute the same code on every player's machine. They can access every player's data all the time. To find every player's characters, use: for index, player in pairs(game.players) do local character = player.character if character ~= nil then -- Do stuff with ...
by sdgmlj
Mon May 23, 2022 1:13 am
Forum: Modding help
Topic: How can I get the "index" of the current character in "script. On_init"
Replies: 4
Views: 417

How can I get the "index" of the current character in "script. On_init"

This is included in multiplayer games. How can I get it? thank you
by sdgmlj
Sat May 21, 2022 4:34 am
Forum: Modding help
Topic: Is there any way to save the data of the table permanently
Replies: 6
Views: 368

Re: Is there any way to save the data of the table permanently

FuryoftheStars wrote: ↑
Fri May 20, 2022 1:21 pm
Yes, but similar to a player trying to change the setting during a running game, (as far as I know) it will not persist between different games/saves.
Thank you. I see
by sdgmlj
Fri May 20, 2022 5:38 am
Forum: Modding help
Topic: Is there any way to save the data of the table permanently
Replies: 6
Views: 368

Re: Is there any way to save the data of the table permanently

The global table cannot be used between different save files. Any β€œsettings” of that nature that you need to persist between different games, you’ll need to use actual settings for (https://wiki.factorio.com/Tutorial:Mod_settings). Note that the user will need to set these from the main menu in ord...

Go to advanced search