Page 2 of 2
Re: on_player_selected_area
Posted: Tue Oct 11, 2022 12:33 pm
by Stringweasel
evandro_6565 wrote: Tue Oct 11, 2022 11:58 am
in the debugger where exactly the location of the launch file would be. in the mod folder.. :
That's visible in the link I showed you. It should be
Code: Select all
mods/
your_mod_1.0.0/
.vscode/
launch.json
settings.json
control.lua
data.lua
etc...
After that I usually just press F5 to start the debugger. Then it will ask you to where your factorio.exe is located. Just follow the prompts.
evandro_6565 wrote: Tue Oct 11, 2022 12:02 pm
I have a question, do you know of a tool to visualize this code: shift = util.by_pixel(x, y) I have to keep opening and closing the game to test the positioning
I don't know of such a tool.
Re: on_player_selected_area
Posted: Tue Oct 11, 2022 12:42 pm
by Pi-C
evandro_6565 wrote: Tue Oct 11, 2022 12:02 pm
I have a question, do you know of a tool to visualize this code:
shift = util.by_pixel(x, y) I have to keep opening and closing the game to test the positioning
I wonder if you could abuse
LuaRendering for testing by plotting on the ground.
Re: on_player_selected_area
Posted: Tue Oct 11, 2022 6:31 pm
by evandro_6565
I found this site I tested it worked...
Re: on_player_selected_area
Posted: Thu Oct 13, 2022 10:26 am
by evandro_6565
a table receiving another table directly only clones the values but does not create another separate table... for example, tab[1].op and op with value 2 when I copy the table to tab[2] the index "op" if it is changed together the value of tab[1] is changed together.
Code: Select all
global.recorder[ tag ] = new_entity
global.recorder[ 1 ] = new_entity
global.recorder[ 2 ] = global.recorder[ 1 ]
I used the code "table.insert" to insert "table.insert( global.recorder[ 1 ], global.recorder[ 2 ] )"
but returns an error
I copied this function to copy the table well it seems it worked but with time an error message appears but the game continues running and the message comes back again
Code: Select all
function table_copy(t)
local t2 = {};
for k,v in pairs(t) do
if type(v) == "table" then
t2[k] = table_copy(v);
else
t2[k] = v;
end
end
return t2;
end

- Sem título.png (956.39 KiB) Viewed 3682 times
Re: on_player_selected_area
Posted: Thu Oct 13, 2022 11:37 am
by Stringweasel
evandro_6565 wrote: Thu Oct 13, 2022 10:26 am
I copied this function to copy the table well it seems it worked but with time an error message appears but the game continues running and the message comes back again
Yeah, if you want a copy of a table then you need to do a deep copy. You're going the right way, but there's an easier way, by using a
built-in library
Code: Select all
local util = require("util")
local foo = { "this is a table" }
local foo_copy = util.deepcopy(foo)
As for that crash you get, I haven't seen that before. But it looks like you're trying to save a
function of a LuaObject in the table, instead of the LuaObject itself. Meaning something like
Code: Select all
function foo(event)
local entity = event.entity
global.bad = entity.launch_rocket -- This trying to save a function which we cannot do in global.
global.good = entity.launch_rocket() -- This is fine because we're executing the function
global.good = entity -- We can safely store LuaObjects in global too
end
However, this is pure speculation, because I don't really know.
Re: on_player_selected_area
Posted: Thu Oct 13, 2022 12:41 pm
by evandro_6565
Stringweasel wrote: Thu Oct 13, 2022 11:37 am
about the
"for_n_of" loop i was using table.remove and i noticed that the loop is stopping

and i reread the flib article and i noticed this
do you know how to remove without stopping the loop
DO NOT delete entires from tbl from within callback, this will break the iteration. Use the deletion flag instead.
Re: on_player_selected_area
Posted: Thu Oct 13, 2022 1:14 pm
by Stringweasel
It explains it in the documentation. The function you give it should return if the current entry should be deleted. I guess it should be something like this:
Code: Select all
event.on_tick(function()
global.from_k = table.for_n_of(extremely_large_table, global.from_k, 10, function(value, key)
-- Do whatever
local should_delete_entry = should_delete(key) -- this is a bool
return nil, should_delete_entry
end)
end)
Re: on_player_selected_area
Posted: Fri Oct 14, 2022 10:31 am
by evandro_6565
worked, returning boolean true value
do you know the code to create this hole through this script

- as.png (587.87 KiB) Viewed 3627 times
Re: on_player_selected_area
Posted: Fri Oct 14, 2022 10:43 am
by Stringweasel
evandro_6565 wrote: Fri Oct 14, 2022 10:31 am
do you know the code to create this hole through this script
Pretty sure it's an entity, as seen here in the
prototype for an explosive rocket
Code: Select all
entity_name = "medium-scorchmark-tintable",
The file is here though, you can even make a sprite out of it:
Code: Select all
Factorio_1.1.69\data\base\graphics\entity\scorchmark\big-scorchmark-top.png
Re: on_player_selected_area
Posted: Fri Oct 14, 2022 11:20 pm
by evandro_6565
here is my repository, I couldn't do the division of the table tab.car, tab.entity but I removed those loops and only the one from the flib was left
Re: on_player_selected_area
Posted: Sat Oct 15, 2022 6:38 am
by Stringweasel
evandro_6565 wrote: Fri Oct 14, 2022 11:20 pm
here is my repository,
I think your profile and/or repository is set to private because I can't open the page

Re: on_player_selected_area
Posted: Sat Oct 15, 2022 10:28 am
by evandro_6565
Stringweasel wrote: Sat Oct 15, 2022 6:38 am
evandro_6565 wrote: Fri Oct 14, 2022 11:20 pm
here is my repository,
I think your profile and/or repository is set to private because I can't open the page
I have this problem, I don't know how to solve it. I think it's because of that
Re: on_player_selected_area
Posted: Sat Oct 15, 2022 10:29 am
by evandro_6565
evandro_6565 wrote: Sat Oct 15, 2022 10:28 am
Stringweasel wrote: Sat Oct 15, 2022 6:38 am
evandro_6565 wrote: Fri Oct 14, 2022 11:20 pm
here is my repository,
I think your profile and/or repository is set to private because I can't open the page
I have this problem, I don't know how to solve it. I think it's because of that

- sm.png (26.68 KiB) Viewed 3576 times
Re: on_player_selected_area
Posted: Sat Oct 15, 2022 1:21 pm
by Stringweasel
I've never seen that before. I would just click `Contact Support` and try to get it fixed somehow

Re: on_player_selected_area
Posted: Sat Oct 15, 2022 2:08 pm
by evandro_6565
Stringweasel wrote: Sat Oct 15, 2022 1:21 pm
I've never seen that before. I would just click `Contact Support` and try to get it fixed somehow
I already sent a message today and I'll have to wait
"Due to the high volume of support calls, it may take up to seven business days for our support engineers to respond."
I already tried to delete the account to open another but the delete button is blocked

Re: on_player_selected_area
Posted: Sun Oct 16, 2022 11:32 am
by evandro_6565
try testing again
the message has been withdrawn
Re: on_player_selected_area
Posted: Sun Oct 16, 2022 1:58 pm
by Stringweasel
Now it works!
Re: on_player_selected_area
Posted: Sun Oct 16, 2022 7:50 pm
by evandro_6565
do you know how to block the player from mining an entity... i want the entity to remain operable but the player cannot mine
Re: on_player_selected_area
Posted: Sun Oct 16, 2022 7:54 pm
by Stringweasel
evandro_6565 wrote: Sun Oct 16, 2022 7:50 pm
do you know how to block the player from mining an entity... i want the entity to remain operable but the player cannot mine
Maybe you can use this?
https://lua-api.factorio.com/latest/Lua ... ty.minable
Or some players seem to listen for the mine event, and then clone the entity again before the player notices. Almost like this one:
https://github.com/Wiwiweb/FactorioUndeletableFluids
Re: on_player_selected_area
Posted: Sun Oct 16, 2022 8:24 pm
by evandro_6565
well it worked...thanks
