Help, game error - no character

Place to get help with not working mods / modding interface.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1654
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Help, game error - no character

Post by Pi-C »

sdgmlj wrote:
Mon Apr 11, 2022 12:17 am
Pi-C wrote:
Sun Apr 10, 2022 8:00 pm
Also, there's this at the top of scripts/respawn.lua:

Code: Select all

--custon event
--/c remote.call("space-exploration", "get_on_player_respawned_event")
--script.on_event(remote.call("space-exploration", "get_on_player_respawned_event"), my_event_handler)
So you must add another function to your remote interface a handler for SE's custom event. But thanks for finding this! This interferes with my mod as well, so now I know about it, I can fix it. :-)
I don't quite understand how I can add it
Like this:

Code: Select all

  if remote.interfaces["space-exploration"] and
      remote.interfaces["space-exploration"]["get_on_player_respawned_event"] then

    local event_id = remote.call("space-exploration", "get_on_player_respawned_event")
    
    script.on_event(event_id, function(event)
    	game.print("SE has respawned a player!\nEvent data: "..serpent.block(event))
    end)

  end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Help, game error - no character

Post by sdgmlj »

Pi-C wrote:
Mon Apr 11, 2022 12:44 am
sdgmlj wrote:
Mon Apr 11, 2022 12:17 am
Pi-C wrote:
Sun Apr 10, 2022 8:00 pm
Also, there's this at the top of scripts/respawn.lua:

Code: Select all

--custon event
--/c remote.call("space-exploration", "get_on_player_respawned_event")
--script.on_event(remote.call("space-exploration", "get_on_player_respawned_event"), my_event_handler)
So you must add another function to your remote interface a handler for SE's custom event. But thanks for finding this! This interferes with my mod as well, so now I know about it, I can fix it. :-)
I don't quite understand how I can add it
Like this:

Code: Select all

  if remote.interfaces["space-exploration"] and
      remote.interfaces["space-exploration"]["get_on_player_respawned_event"] then

    local event_id = remote.call("space-exploration", "get_on_player_respawned_event")
    
    script.on_event(event_id, function(event)
    	game.print("SE has respawned a player!\nEvent data: "..serpent.block(event))
    end)

  end
Such a mistake has occurred:
Attempt to remote call outside of an event.
stack traceback:
[C]: in function 'call'

Pi-C
Smart Inserter
Smart Inserter
Posts: 1654
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Help, game error - no character

Post by Pi-C »

sdgmlj wrote:
Mon Apr 11, 2022 1:13 am

Such a mistake has occurred:
Attempt to remote call outside of an event.
stack traceback:
[C]: in function 'call'
Oh, of course! I've defined all my event handlers in a function that is called from script.on_init, script.on_configuration_changed, and script.on_load. So something like this should work for:

Code: Select all

local function add_se_respawn_event()
  if remote.interfaces["space-exploration"] and
      remote.interfaces["space-exploration"]["get_on_player_respawned_event"] then

    local event_id = remote.call("space-exploration", "get_on_player_respawned_event")
    
    script.on_event(event_id, function(event)
    	game.print("SE has respawned a player!\nEvent data: "..serpent.block(event))
    end)

  end
end


script.on_init(function()
  add_se_respawn_event()

  ...
  
end)


script.on_configuration_changed(function(event)
  add_se_respawn_event()

  ...
end)


script.on_load(function()
    add_se_respawn_event()

  ...

end)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Help, game error - no character

Post by sdgmlj »

Pi-C wrote:
Mon Apr 11, 2022 6:44 am
sdgmlj wrote:
Mon Apr 11, 2022 1:13 am

Such a mistake has occurred:
Attempt to remote call outside of an event.
stack traceback:
[C]: in function 'call'
Oh, of course! I've defined all my event handlers in a function that is called from script.on_init, script.on_configuration_changed, and script.on_load. So something like this should work for:

Code: Select all

local function add_se_respawn_event()
  if remote.interfaces["space-exploration"] and
      remote.interfaces["space-exploration"]["get_on_player_respawned_event"] then

    local event_id = remote.call("space-exploration", "get_on_player_respawned_event")
    
    script.on_event(event_id, function(event)
    	game.print("SE has respawned a player!\nEvent data: "..serpent.block(event))
    end)

  end
end


script.on_init(function()
  add_se_respawn_event()

  ...
  
end)


script.on_configuration_changed(function(event)
  add_se_respawn_event()

  ...
end)


script.on_load(function()
    add_se_respawn_event()

  ...

end)
OK, the problem is solved. Thank you

Post Reply

Return to “Modding help”