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.
Custom Scenario Errors: Please Help!
-
- Burner Inserter
- Posts: 5
- Joined: Thu Feb 22, 2018 12:36 am
- Contact:
Custom Scenario Errors: Please Help!
- Attachments
-
- control.lua
- (11 KiB) Downloaded 164 times
Re: Custom Scenario Errors: Please Help!
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.
-
- Burner Inserter
- Posts: 5
- Joined: Thu Feb 22, 2018 12:36 am
- Contact:
Re: Custom Scenario Errors: Please Help!
Could you elaborate on "faulty"? Is it something wrong with story_table or under script.on_init?
- Deadly-Bagel
- Smart Inserter
- Posts: 1498
- Joined: Wed Jul 13, 2016 10:12 am
- Contact:
Re: Custom Scenario Errors: Please Help!
As per the error "control.lua:6" Look at line 6 of control.lua:
"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.players[1].force.disable_all_prototypes()
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.
Re: Custom Scenario Errors: Please Help!
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.Deadly-Bagel wrote:As per the error "control.lua:6" Look at line 6 of control.lua:
"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.players[1].force.disable_all_prototypes()
Code: Select all
game.player[1].force.disable_all_prototypes() game.player[1].force.clear_chart()
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- Deadly-Bagel
- Smart Inserter
- Posts: 1498
- Joined: Wed Jul 13, 2016 10:12 am
- Contact:
Re: Custom Scenario Errors: Please Help!
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.
-
- Burner Inserter
- Posts: 5
- Joined: Thu Feb 22, 2018 12:36 am
- Contact:
Re: Custom Scenario Errors: Please Help!
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?Bilka wrote: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.Deadly-Bagel wrote:As per the error "control.lua:6" Look at line 6 of control.lua:
"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.players[1].force.disable_all_prototypes()
Code: Select all
game.player[1].force.disable_all_prototypes() game.player[1].force.clear_chart()