Page 1 of 1
[1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Sun Nov 29, 2020 7:47 am
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?
Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Sun Nov 29, 2020 8:34 am
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!
Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Sun Nov 29, 2020 9:30 am
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
Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Sun Nov 29, 2020 1:19 pm
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.
Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Sun Nov 29, 2020 1:21 pm
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.
Re: [1.1.1] Error info doesn't provide useful info when I create "grenade" entity.
Posted: Mon Nov 30, 2020 2:43 am
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.