Page 1 of 1
Custom Scenario Errors: Please Help!
Posted: Thu Feb 22, 2018 1:08 am
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.
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 3:22 am
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.
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 3:54 am
by DarkSeahorse635
Could you elaborate on "faulty"? Is it something wrong with story_table or under script.on_init?
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 9:46 am
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()
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 10:15 am
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.
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 10:25 am
by Deadly-Bagel
Ah. Don't mind me then ^^ too early to be trying lol
Re: Custom Scenario Errors: Please Help!
Posted: Fri Feb 23, 2018 3:32 pm
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?