[1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Bugs that are actually features.
Post Reply
yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

[1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by yagaodirac »

If I write
game.players[1].surface.create_entity{name = "grenade", position = {0,0}, target=game.players[1]}
inside my code, I get an error info. It says that the speed is not in ROOT. But what is the speed? surface.create_entity function doesn't receive a parameter named speed. Does it have anything to do with the prototype inside the data.lua?
Or, is it possible to create "grenade" entity?

When I throw a grenade, the surface.find_entities returns me a table with some entity named grenade. When I tried to create it from code, even if I specified the target, it still refused to work. The error info pointed out that a speed field is not specified, but I found no clue about it.
Any idea? How can I create a grenade entity?

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

Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by Pi-C »

yagaodirac wrote:
Sun Nov 29, 2020 7:47 am
If I write
game.players[1].surface.create_entity{name = "grenade", position = {0,0}, target=game.players[1]}
inside my code, I get an error info. It says that the speed is not in ROOT. But what is the speed? surface.create_entity function doesn't receive a parameter named speed. Does it have anything to do with the prototype inside the data.lua?
Or, is it possible to create "grenade" entity?
Yes, it's about prototype data. According to the wiki (see the specs on the right side), grenades are instances of the projectile prototype. Hope that helps! :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5151
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by Klonan »

yagaodirac wrote:
Sun Nov 29, 2020 7:47 am
If I write
game.players[1].surface.create_entity{name = "grenade", position = {0,0}, target=game.players[1]}
inside my code, I get an error info. It says that the speed is not in ROOT. But what is the speed? surface.create_entity function doesn't receive a parameter named speed. Does it have anything to do with the prototype inside the data.lua?
Or, is it possible to create "grenade" entity?

When I throw a grenade, the surface.find_entities returns me a table with some entity named grenade. When I tried to create it from code, even if I specified the target, it still refused to work. The error info pointed out that a speed field is not specified, but I found no clue about it.
Any idea? How can I create a grenade entity?
the 'ROOT' is the table you have given to the create_entity: `{name = "grenade", position = {0,0}, target=game.players[1]}`
It is missing speed, which is how fast it should move

It is listed in the create entity docs under 'Additional entity-specific parameters'
https://lua-api.factorio.com/latest/Lua ... ate_entity

yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by yagaodirac »

Klonan wrote:
Sun Nov 29, 2020 9:30 am
yagaodirac wrote:
Sun Nov 29, 2020 7:47 am
If I write
game.players[1].surface.create_entity{name = "grenade", position = {0,0}, target=game.players[1]}
inside my code, I get an error info. It says that the speed is not in ROOT. But what is the speed? surface.create_entity function doesn't receive a parameter named speed. Does it have anything to do with the prototype inside the data.lua?
Or, is it possible to create "grenade" entity?

When I throw a grenade, the surface.find_entities returns me a table with some entity named grenade. When I tried to create it from code, even if I specified the target, it still refused to work. The error info pointed out that a speed field is not specified, but I found no clue about it.
Any idea? How can I create a grenade entity?
the 'ROOT' is the table you have given to the create_entity: `{name = "grenade", position = {0,0}, target=game.players[1]}`
It is missing speed, which is how fast it should move

It is listed in the create entity docs under 'Additional entity-specific parameters'
https://lua-api.factorio.com/latest/Lua ... ate_entity
Thank you very much. Very helpful. One more suggestion. The create_entity function is literally too complex. I suggest more example and more detail explained with the examples including this one.

yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by yagaodirac »

Pi-C wrote:
Sun Nov 29, 2020 8:34 am
yagaodirac wrote:
Sun Nov 29, 2020 7:47 am
If I write
game.players[1].surface.create_entity{name = "grenade", position = {0,0}, target=game.players[1]}
inside my code, I get an error info. It says that the speed is not in ROOT. But what is the speed? surface.create_entity function doesn't receive a parameter named speed. Does it have anything to do with the prototype inside the data.lua?
Or, is it possible to create "grenade" entity?
Yes, it's about prototype data. According to the wiki (see the specs on the right side), grenades are instances of the projectile prototype. Hope that helps! :-)
Very glad to see you again. With answers from both of you, I already know what to do next. Thanks.

yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.

Post by yagaodirac »

Thank you for helping. Here's the final result.
local simple_grenade =
{
acceleration = 0.005,
action = {
{
action_delivery = {
target_effects = {
{
damage = {
amount = 35,
type = "explosion"
},
type = "damage"
},
},
type = "instant"
},
radius = 6.5,
type = "area"
}
},
name = "simple-grenade",
type = "projectile"
}

I didn't test what the acceleration value does. This already works.

Post Reply

Return to “Not a bug”