Search found 3602 matches

by DaveMcW
Tue May 17, 2022 6:02 pm
Forum: Modding help
Topic: CONSUME FISH WHEN EXECUTING A CUSTOM ACTION
Replies: 3
Views: 98

Re: CONSUME FISH WHEN EXECUTING A CUSTOM ACTION

Code: Select all

local consumed = player.remove_item{name="raw-fish", count=1}
if consumed == 1 then
  -- teleport code
else
  player.surface.create_entity{name="flying-text", position=player.position, render_player_index=player.index, color={r=1}, text="Out of fish"}
end
by DaveMcW
Sun May 15, 2022 1:31 am
Forum: Modding discussion
Topic: Speaker alert_message is read only?
Replies: 2
Views: 64

Re: Speaker alert_message is read only?

You have to write the table back to entity.alert_parameters.

Code: Select all

local parameters = event.entity.alert_parameters
parameters.alert_message = "+"
event.entity.alert_parameters = parameters
by DaveMcW
Wed May 11, 2022 1:02 am
Forum: Modding help
Topic: Arachnids, would you like to know more...? Data.raw function replacement help!
Replies: 8
Views: 280

Re: Arachnids, would you like to know more...? Data.raw function replacement help!

You don't have to use those functions if you don't understand them.

Check out the data.raw dump (search for blood-puddle) to see what the final data.raw table should look like. How you get there is up to you.
by DaveMcW
Tue May 10, 2022 12:14 am
Forum: Modding help
Topic: How to get the translation?
Replies: 19
Views: 490

Re: How to get the translation?

Paste this in the console.

Code: Select all

/c
script.on_event(defines.events.on_string_translated, function(event)
  game.print(event.result)
end)
game.player.request_translation({"item-name.iron-plate"})
by DaveMcW
Thu May 05, 2022 1:58 pm
Forum: Modding help
Topic: What happens with integer overflow?
Replies: 12
Views: 455

Re: What happens with integer overflow?

C++ integers wrap around to the minimum value. This does not affect the number itself, but any logic expecting the number to be large could fail/crash.

game.tick overflow is a popular source of bugs, some of which have been fixed. I'm not sure they are all fixed though.
by DaveMcW
Thu May 05, 2022 1:50 pm
Forum: Modding help
Topic: What happens with integer overflow?
Replies: 12
Views: 455

Re: What happens with integer overflow?

All Lua 5.2 numbers are double precision floats. So it almost impossible to make them overflow.
by DaveMcW
Tue Apr 26, 2022 2:03 pm
Forum: Modding help
Topic: Adding a new ressource to the game
Replies: 6
Views: 292

Re: Adding a new ressource to the game

If you are comfortable with control.lua scripting, you could add a simple-entity on top of each resource with the render_layer you want.

You would have to handle on_chunk_generated and on_resource_depleted events.
by DaveMcW
Tue Apr 26, 2022 6:31 am
Forum: Modding help
Topic: on_player_dropped_item How to get item.name
Replies: 7
Views: 191

Re: on_player_dropped_item How to get item.name

hackamod wrote:
Tue Apr 26, 2022 4:51 am
the proper way to delete the item_on_ground entity?
The same way you delete any LuaEntity.

Code: Select all

/c game.player.selected.destroy()
by DaveMcW
Mon Apr 25, 2022 11:04 pm
Forum: Modding help
Topic: on_player_dropped_item How to get item.name
Replies: 7
Views: 191

Re: on_player_dropped_item How to get item.name

Which led me to believe this "stack" is the best handle to an item out in the world, laying on the ground...because there is no inventory slot for it... Correct, every item must be accessed through a LuaItemStack object. You can get this from the .stack property of an event. Or the .stack...
by DaveMcW
Mon Apr 25, 2022 2:05 pm
Forum: Modding help
Topic: Spreading a table out over several ticks
Replies: 22
Views: 678

Re: Spreading a table out over several ticks

Here is how I do it in burner fuel bonus . global.burners is the table, global.burner_index is the next index to read. Note that I increment the index before using it, this allows me to delete a table entry in the update function without crashing the loop. script.on_event(defines.events.on_tick, fun...
by DaveMcW
Sat Apr 23, 2022 7:19 pm
Forum: Medium/Big/Gigantic Sized Structures
Topic: UPS Wars 5: Low density structure (LDS)
Replies: 2
Views: 698

Re: UPS Wars 5: Low density structure (LDS)

Here are the results. The winning design was made by Stevetrov. It runs at 1838 UPS and uses 53 ore patches. ups-wars-5-winner-1.jpg The best train entry was made by DaveMcW. It runs at 1799 UPS and uses 47 ore patches. ups-wars-5-winner-2.jpg The best off-resource entry was made by DaveMcW. It runs...
by DaveMcW
Sat Apr 09, 2022 11:05 pm
Forum: Gameplay Help
Topic: I Can't Get to the Equipment Grid
Replies: 6
Views: 240

Re: I Can't Get to the Equipment Grid

What does the tooltip say when you mouse over the armor?
by DaveMcW
Sat Apr 09, 2022 2:59 pm
Forum: Modding help
Topic: Play random audio file out of some folder
Replies: 2
Views: 118

Re: Play random audio file out of some folder

You have to list all the sounds in data.lua, but they can be random at runtime. data.lua: data:extend{ { type = "sound", name = "my-random-sound", variations = { {filename = "__my-mod__/sound/sound1.ogg"}, {filename = "__my-mod__/sound/sound2.ogg"}, }, allow_r...
by DaveMcW
Tue Apr 05, 2022 7:15 pm
Forum: Modding help
Topic: How to detect vehicles running out of fuel
Replies: 4
Views: 341

Re: How to detect vehicles running out of fuel

The concept is simple, but the implementation is not. There is no event support. You have to track everything yourself using global.tables and the on_tick event.

For the fuel value, look at locomotive.burner.heat and locomotive.burner.remaining_burning_fuel
by DaveMcW
Tue Apr 05, 2022 7:10 pm
Forum: Modding help
Topic: MOD Burner Filter Inserter -- Refuel from belt issue
Replies: 2
Views: 228

Re: MOD Burner Filter Inserter -- Refuel from belt issue

There is no easy fix.

This sounds like it should be a modding interface request or bug report.
by DaveMcW
Tue Apr 05, 2022 10:36 am
Forum: Combinator Creations
Topic: UPS optimized 12-beacon smelting - w/minimal circuits
Replies: 179
Views: 15586

Re: UPS optimized 12-beacon smelting - w/minimal circuits

You can compress the mining drills an additional 1 tile vertically and 3 tiles horizontally. 0eNrdXNtu4zgM/Rc/JwNdbSnY/ZJFEeSidoRN7MCXYooi/75y3EmyjtyKZIBB+jJoHEdHpI5IiqTmPVvvOneofdlmi/fMb6qyyRb/vGeNfylXu/5Z+3Zw2SLzrdtns6xc7ftPbuc2be038+euLlcblx1nmS+37le24MenWebK1rfeDWOdPrwty26/dnV44TzK2q0CYBj1UDXh9f...
by DaveMcW
Sun Apr 03, 2022 3:07 am
Forum: Combinator Creations
Topic: UPS optimized 12-beacon smelting - w/minimal circuits
Replies: 179
Views: 15586

Re: UPS optimized 12-beacon smelting - w/minimal circuits

Here is the 10.4 beacon blueprint modified to fit on a 23x29 ore patch. I also made the combinator logic easier to understand. 0eNrdXW1u4zYQvcpCQP/ZC36LDNqTFEHgxEpWqC0bshxssMgBepBerCcpZXtjVSJlzQzT1PnTbhyHj5x5HJFvhuKP7H61L7Z1WTXZzY+sfNhUu+zm9x/ZrnyqFqv2s+ZlW2Q3WdkU62yWVYt1+1OxKh6aunyYP+7ravFQZK+zrKyW...
by DaveMcW
Sun Apr 03, 2022 1:31 am
Forum: Modding help
Topic: Can you realize the dynamic conversion of formula
Replies: 4
Views: 328

Re: Can you realize the dynamic conversion of formula

No, not with a recipe. But you can do it with a unique furnace for each output. data:extend{ { type = "recipe-category", name = "transformation-iron-ore", }, { type = "recipe-category", name = "transformation-copper-ore", }, { type = "recipe", name =...
by DaveMcW
Sun Mar 20, 2022 9:26 am
Forum: Gameplay Help
Topic: Simple Questions and Short Answers
Replies: 1516
Views: 294714

Re: Simple Questions and Short Answers

You can't, unless you mod the game.

If you are creating a mod, the property you want to set is fast_replaceable_group.

Go to advanced search