Custom Scenario Errors: Please Help!

Place to get help with not working mods / modding interface.
Post Reply
DarkSeahorse635
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu Feb 22, 2018 12:36 am
Contact:

Custom Scenario Errors: Please Help!

Post by DarkSeahorse635 »

I was inspired by a recent Friday Facts to create a custom scenario similar to the ones in the base game. In short, the player must secure the perimeter of a small pre-built base, find a train yard with an artillery turret and enough supplies to launch a rocket, and build a train line across the map to a launching silo and launch the turret to win. Unfortunately, I had no experience with c++ before opening up the control folders and the code is giving me a hard time.

Upon running the scenario, the error I get is "Error while running on_init: ...Data/Roaming/Factorio/temp/currently-playing/control.lua:6: attempt to index field '?' (a nil value)"

I'm aware that the problem is with the arguments for "on_init", but I cant find the "currently-playing" folder in "Roaming/Factorio/temp" so I don't know how the function works. Please Help! thanks in advance!!

Notes: I used map editor to build the map and the base. I used the "tag" feature to tag entities that I wanted to fill with items at the start of the game.
ldswagon = low density structure wagon
rcu = rocket control unit
rf = rocket fuel

The control folder should be below. Let me know if anything else is needed.
Attachments
control.lua
(11 KiB) Downloaded 129 times

User avatar
unfunf22
Inserter
Inserter
Posts: 31
Joined: Fri May 20, 2016 9:00 pm
Contact:

Re: Custom Scenario Errors: Please Help!

Post by unfunf22 »

this Data/Roaming/Factorio/temp/currently-playing/ can be found when you play the game and it not crashing to desktop but its not important because your scenario is faulty.

DarkSeahorse635
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu Feb 22, 2018 12:36 am
Contact:

Re: Custom Scenario Errors: Please Help!

Post by DarkSeahorse635 »

Could you elaborate on "faulty"? Is it something wrong with story_table or under script.on_init?

User avatar
Deadly-Bagel
Smart Inserter
Smart Inserter
Posts: 1498
Joined: Wed Jul 13, 2016 10:12 am
Contact:

Re: Custom Scenario Errors: Please Help!

Post by Deadly-Bagel »

As per the error "control.lua:6" Look at line 6 of control.lua:

Code: Select all

game.players[1].force.disable_all_prototypes()
"players" isn't a property of "game", you're looking for "player" so when you try to index "players" it's throwing an error.

Code: Select all

  game.player[1].force.disable_all_prototypes()
  game.player[1].force.clear_chart()
Money might be the root of all evil, but ignorance is the heart.

Bilka
Factorio Staff
Factorio Staff
Posts: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Custom Scenario Errors: Please Help!

Post by Bilka »

Deadly-Bagel wrote:As per the error "control.lua:6" Look at line 6 of control.lua:

Code: Select all

game.players[1].force.disable_all_prototypes()
"players" isn't a property of "game", you're looking for "player" so when you try to index "players" it's throwing an error.

Code: Select all

  game.player[1].force.disable_all_prototypes()
  game.player[1].force.clear_chart()
Wtf are you talking about...? game.player is only available in the console, game.players is the list of players. The issue is that on_init no player exists because it hasnt been created yet. OP could access the force directly instead, using game.forces.player.disable_all_prototypes() etc.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Deadly-Bagel
Smart Inserter
Smart Inserter
Posts: 1498
Joined: Wed Jul 13, 2016 10:12 am
Contact:

Re: Custom Scenario Errors: Please Help!

Post by Deadly-Bagel »

Ah. Don't mind me then ^^ too early to be trying lol
Money might be the root of all evil, but ignorance is the heart.

DarkSeahorse635
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu Feb 22, 2018 12:36 am
Contact:

Re: Custom Scenario Errors: Please Help!

Post by DarkSeahorse635 »

Bilka wrote:
Deadly-Bagel wrote:As per the error "control.lua:6" Look at line 6 of control.lua:

Code: Select all

game.players[1].force.disable_all_prototypes()
"players" isn't a property of "game", you're looking for "player" so when you try to index "players" it's throwing an error.

Code: Select all

  game.player[1].force.disable_all_prototypes()
  game.player[1].force.clear_chart()
Wtf are you talking about...? game.player is only available in the console, game.players is the list of players. The issue is that on_init no player exists because it hasnt been created yet. OP could access the force directly instead, using game.forces.player.disable_all_prototypes() etc.
I'm having trouble actually creating this character. If no player exists, the recipe/technology/character inventory lists won't work because there is no player to index. I used the code from the campaigns to write that part which accomplishes this task with no issue. How do the campaigns create a character?

Post Reply

Return to “Modding help”