player.cursor_ghost.name is LuaItemPrototype?

Place to get help with not working mods / modding interface.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

player.cursor_ghost.name is LuaItemPrototype?

Post by ownlyme »

I'm not sure if this is a bug, but sometimes the .name field doesnt contain the name, but an object...
for example for player.cursor_ghost
you'd expect .name to be a string, right?
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
robot256
Smart Inserter
Smart Inserter
Posts: 1246
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: player.cursor_ghost.name is LuaItemPrototype?

Post by robot256 »

It's weird that it's called "name", but that's the intended behavior. I found it a while ago and they updated the docs.

See:
https://lua-api.factorio.com/latest/con ... DPair.html

Linked from:
https://lua-api.factorio.com/latest/cla ... rsor_ghost
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: player.cursor_ghost.name is LuaItemPrototype?

Post by ownlyme »

so when you wanna read the name you write "something.name.name" ? kinda weird but ok
especially since it's inconsistent
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
robot256
Smart Inserter
Smart Inserter
Posts: 1246
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: player.cursor_ghost.name is LuaItemPrototype?

Post by robot256 »

Yup that's right. I agree it really ought to be named "item" or something like that. And so far only seems to affect cursor_ghost?
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
User avatar
gangerM
Burner Inserter
Burner Inserter
Posts: 18
Joined: Thu Nov 28, 2024 5:32 pm
Contact:

Re: player.cursor_ghost.name is LuaItemPrototype?

Post by gangerM »

I made a similar bug report a while ago; 123575
Here it is that get_filter(1) gives a prototype for a name or a string depending on the type of entity it is called on, I did not realize there were other cases.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: player.cursor_ghost.name is LuaItemPrototype?

Post by ownlyme »

https://lua-api.factorio.com/latest/cla ... ly_burning

currently_burning.name is also item prototype

meanwhile that.burnt_result.name is a string again.

this is ridiculous
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Post Reply

Return to “Modding help”