Page 1 of 1

[Bug, Fixed] Simple instant blueprint mod

Posted: Wed Jun 29, 2016 5:57 pm
by DemiPixel
Loads of coding experience, little to none with Lua. Here's my code:

Code: Select all

script.on_event(defines.events.on_built_entity, function(ev) 
    game.players[1].print(ev.created_entity.name .. ", " .. ev.created_entity.ghost_name)
    game.players[1].print(tostring(ev.created_entity.revive()))
end)
All I should need is ev.created_entity.revive() however I've added a little bit more for testing.

If I comment out the second line, when placing something like a long line of lamps with a combinator at the end, it only prints one lamp and one combinator (do the others get cut off or something?)

If I uncomment the second line, Factorio is unhappy and crashes, provided an error in the logs that is not very helpful:

Code: Select all

  41.712 Applying migration: Base Mod: 2016-04-22_Factorio_0.13.0.lua
  41.738 Applying migration: Base Mod: 2016-06-15_Factorio_0.13.0.lua
  41.741 Applying migration: Base Mod: 2016-06-23_Factorio_0.13.0.lua
  41.747 Applying migration: Base Mod: 2016-06-26_Factorio_0.13.0.lua
  41.749 Applying migration: Base Mod: 2016-06-27_Factorio_0.13.0.lua
  41.751 Applying migration: Base Mod: 2016-06-28_Factorio_0.13.0.lua
  41.759 Checksum for script /Users/Me/Library/Application Support/factorio/temp/currently-playing/control.lua: 900459546
  41.761 Checksum for script __instant-blueprint__/control.lua: 3098547080
  45.316 Error CrashHandler.cpp:183: Received SIGSEGV
Factorio crashed. Generating symbolized stacktrace, please wait ...
#0  0x10059e172 in Logger::logStacktrace(StackTraceInfo*) (in factorio) (Logger.cpp:382)
#1  0x1005970f9 in CrashHandler::writeStackTrace() (in factorio) (CrashHandler.cpp:85)
#2  0x10059708e in CrashHandler::SignalHandler(int) (in factorio) (CrashHandler.cpp:188)
#3  0x7fff8829952a in 0x7fff8829952a
#4  0x5466ea in 0x005466ea (in factorio)
#5  0x10009ab00 in ManualBuilder::buildItem(InputAction::BuildItemParameters const&, ForceID, ID<EntityPrototype, unsigned short>, bool, bool) (in factorio) (ManualBuilder.cpp:446)
#6  0x10009aa18 in CharacterController::buildItem(InputAction::BuildItemParameters const&) (in factorio) (CharacterController.cpp:401)
#7  0x1002537dc in GameActionHandler::buildItem(InputAction const&, Controller*) (in factorio) (GameActionHandler.cpp:595)
#8  0x10024ee1c in GameActionHandler::actionPerformed(InputAction const&) (in factorio) (GameActionHandler.cpp:286)
#9  0x1003bc8d7 in InputHandler::flushActions(bool) (in factorio) (InputHandler.cpp:44)
#10 0x10024f417 in GameActionHandler::update() (in factorio) (GameActionHandler.cpp:327)
#11 0x100421edf in MainLoop::gameUpdateStep(MultiplayerManager*, Scenario*, AppManager*, MainLoop::HeavyMode) (in factorio) (MainLoop.cpp:325)
#12 0x100423153 in MainLoop::updateLoop(ThreadBarrier*, boost::chrono::time_point<boost::chrono::steady_clock, boost::chrono::duration<long long, boost::ratio<1l, 1000000000l> > >*, boost::chrono::time_point<boost::chrono::steady_clock, boost::chrono::duration<long long, boost::ratio<1l, 1000000000l> > >*, bool*, bool, MainLoop::HeavyMode) (in factorio) (MainLoop.cpp:472)
#13 0x1005a58da in Thread::loop() (in factorio) (Thread.cpp:34)
#14 0x100b22946 in boost::(anonymous namespace)::thread_proxy(void*) (in factorio) + 54
#15 0x7fff9076399d in 0x7fff9076399d
#16 0x7fff9076391a in 0x7fff9076391a
#17 0x7fff90761351 in 0x7fff90761351
  50.079 Error CrashHandler.cpp:85: Map tick at moment of crash: 5531370
  50.079 Error Util.cpp:77: Unexpected error occurred. You can help us to solve the problem by posting the contents of the log file on the Factorio forums.
 119.224 Received SIGTERM, shutting down

Re: Simple instant blueprint mod

Posted: Wed Jun 29, 2016 7:01 pm
by prg
The on_built_entity handler gets called the number of times I'd expect it to when placing a blueprint, what you're seeing is probably just that player.print() suppresses duplicated lines. Try log() or a plain print() and have a look at stdout. I can confirm the crash though. You should report that as a bug. It only crashes when using a blueprint, not when shift-clicking to create a ghost.

Re: Simple instant blueprint mod

Posted: Wed Jun 29, 2016 11:01 pm
by DemiPixel
prg wrote:The on_built_entity handler gets called the number of times I'd expect it to when placing a blueprint, what you're seeing is probably just that player.print() suppresses duplicated lines. Try log() or a plain print() and have a look at stdout. I can confirm the crash though. You should report that as a bug. It only crashes when using a blueprint, not when shift-clicking to create a ghost.
Reported, fixed for 0.13.2

Re: [Bug, Fixed] Simple instant blueprint mod

Posted: Sat Jul 02, 2016 12:41 pm
by Schorty
Hi there,

your mod doesn't work with concrete. Just to let you know. Would be cool, if you could fix that!

Greetings,
Schorty