Mod changes in 0.13
Posted: Fri May 13, 2016 4:23 pm
by Rseding91
With 0.13 nearing and the list of changes getting closer to being "final" I figured now is a good time to let everyone know about breaking changes coming to the mod API in 0.13.
And just so you're not discouraged by those breaking changes this is the list of additions/new things coming in 0.13 related to the mod API:
BREAKING CHANGES
Most of these changes are simple find->replace changes but a few of them will completely break some mods that weren't written correctly (game.player instead of the correct game.players[index]).- Moved LuaGame::daytime/wind/wind_orientation/wind_orientation_change/peaceful_mode to LuaSurface.
- Unified prototype names to be consistant with ingame names. (basic-transport-belt->transport-belt, *transport-belt-to-ground->*underground-belt, basic-splitter->splitter,
basic-inserter->inserter, basic-mining-drill->electric-mining-drill, basic_beacon->beacon, basic-bullet-magazine->firearm-magazine, piercing-bullet-magazine->piercing-rounds-magazine,
basic-grenade->grenade, basic-armor->light-armor, basic-modular-armor->modular-armor, basic-laser-defense-equipment->personal-laser-defense-equipment,
basic-exoskeleton-equipment->exoskeleton-equipment)
- Added LuaInventory::get_filter, set_filter, has_filters, can_set_filter methods to set/get/clear filters on inventories that support them.
- Changed LuaEntity::get_filter/set_filter parameters around to match the inventory versions. They also now only work on inserter filters.
- Renamed some defines (groupstate->group_state, circuitconnector->circuit_connector, circuitconditionindex->circuit_condition_index, trainstate->train_state)
- Removed game.regenerate_tiles().
- Removed game.get_player() and game.get_surface(): game.players[] and game.surfaces[] can be used instead.
- Changed game.players, game.surfaces, game.entity_prototypes, game.item_prototypes, game.fluid_prototypes, force.recipes, force,technologies
to use custom access + iterator objects for improved performance.
- Changed game.players[] to work with both the player index and the player name.
- Changed "defines" so they're available by default and removed the defines.lua file.
- Renamed LuaForce::logistic_robot_storage_modifier -> logistic_robot_storage_bonus to better match what it does
- game.player has been removed (use game.players[#] and associated event.player_index during events).
- game.local_player has been renamed to game.player and now works through remote calls.
- Unified prototype names to be consistant with ingame names. (basic-transport-belt->transport-belt, *transport-belt-to-ground->*underground-belt, basic-splitter->splitter,
basic-inserter->inserter, basic-mining-drill->electric-mining-drill, basic_beacon->beacon, basic-bullet-magazine->firearm-magazine, piercing-bullet-magazine->piercing-rounds-magazine,
basic-grenade->grenade, basic-armor->light-armor, basic-modular-armor->modular-armor, basic-laser-defense-equipment->personal-laser-defense-equipment,
basic-exoskeleton-equipment->exoskeleton-equipment)
- Added LuaInventory::get_filter, set_filter, has_filters, can_set_filter methods to set/get/clear filters on inventories that support them.
- Changed LuaEntity::get_filter/set_filter parameters around to match the inventory versions. They also now only work on inserter filters.
- Renamed some defines (groupstate->group_state, circuitconnector->circuit_connector, circuitconditionindex->circuit_condition_index, trainstate->train_state)
- Removed game.regenerate_tiles().
- Removed game.get_player() and game.get_surface(): game.players[] and game.surfaces[] can be used instead.
- Changed game.players, game.surfaces, game.entity_prototypes, game.item_prototypes, game.fluid_prototypes, force.recipes, force,technologies
to use custom access + iterator objects for improved performance.
- Changed game.players[] to work with both the player index and the player name.
- Changed "defines" so they're available by default and removed the defines.lua file.
- Renamed LuaForce::logistic_robot_storage_modifier -> logistic_robot_storage_bonus to better match what it does
- game.player has been removed (use game.players[#] and associated event.player_index during events).
- game.local_player has been renamed to game.player and now works through remote calls.
And just so you're not discouraged by those breaking changes this is the list of additions/new things coming in 0.13 related to the mod API:
ADDITIONS
As with last time: the list is not finalized so things might change slightly (not likely) and there might be a few small things we didn't include in the lists (by mistake). If you've got any questions just ask.- Added LuaEntity::held_stack_position. It tells you the world position of the inserter arm.
- Added LuaGame::delete_surface. Deletes the surface passed in if the surface is deletable.
- Added invalid parameter error for data.extend function.
- Added item_pickup_distance and loot_pickup_distance to player definition.
- Added LuaItemStack::create_blueprint() - sets up a blueprint as if a player did it.
- Added LuaItemStack::build_blueprint() - builds a blueprint as if the player built it in the world.
- Added LuaSurface::deconstruct_area() - deconstructs an area as if the player did it.
- Added LuaSurface::cancel_deconstruct_area() - cancels deconstruction over an area as if the player did it.
- Added on_pre_entity_settings_pasted and on_entity_settings_pasted events that pass the source and destination entities involved.
- Added the ability to define additional_pastable_entities for an entity which allows copy-paste between that entity type and the defined destination types.
Useful in conjunction with the new copy-paste events.
- Added "robot" to the robot related events.
- Added "chunk_position" to the on_sector_scanned event.
- Added optional "player_index" to on_marked_for_deconstruction/on_canceled_deconstruction when fired due to player actions.
This field is nil when fired from from script/non player action.
- Added LuaEntity::crafting_progress/bonus_progress write.
- Added LuaForce:: item/fluid/resource/build counterparts to kill_counts.
- Added LuaFlowStatistics - used to read/write statistics data related to a given force (production, kills, etc).
- Added LuaGame::disable_replay() - disables the replay for the current save game.
- Added several player related events: on_player_cursor_stack_changed, on_player_main_inventory_changed, on_player_quickbar_inventory_changed,
on_player_tool_inventory_changed, on_player_armor_inventory_changed, on_player_ammo_inventory_changed, on_player_gun_inventory_changed,
on_player_placed_equipment, on_player_removed_equipment, on_pre_player_died, on_player_died, on_player_respawned, on_player_joined_game, on_player_left_game
- Added events for tile building: on_player_built_tile, on_player_mined_tile, on_robot_built_tile, on_robot_mined_tile
- Added a new item type "selection-tool" that fires the events on_player_selected_area and on_player_alt_selected_area.
- Construction robots will now use any available repair tool items instead of a fixed single item defined in the prototype for the robot.
- Added LuaEntity::damage_dealt/kills read/write - usable with turrets.
- Added LuaGameScript::active_mods - a table of active mod names to mod versions.
- Added LuaEquipmentGrid::get - gets the equipment at the given equipment grid position or nil if none.
- Added LuaEntity::player, returns the player connected to the character entity.
- Added LuaPlayer::get_craftable_count/begin_crafting/cancel_crafting/crafting_queue to read/write crafting information for a player.
- Various indicator and game icons are defined in the utility-sprites objects, so it is now moddable.
- Added new research options: character-crafting-speed, character-mining-speed, character-running-speed, character-build-distance, character-item-drop-distance,
character-reach-distance, character-resource-reach-distance, character-item-pickup-distance, character-loot-pickup-distance, character-inventory-slots-bonus,
deconstruction-time-to-live, character-health-bonus
- Added modifiers to the character entity that stack with the force research bonuses but are unique to the character: character_crafting_speed_modifier, character_mining_speed_modifier,
character_running_speed_modifier, character_build_distance_bonus, character_item_drop_distance_bonus, character_reach_distance_bonus, character_resource_reach_distance_bonus,
character_item_pickup_distance_bonus, character_loot_pickup_distance_bonus, quickbar_count_bonus, character_inventory_slots_bonus, character_logistic_slot_count_bonus,
character_trash_slot_count_bonus, character_maximum_following_robot_count_bonus, character_health_bonus
- Added LuaTilePrototype accessible from LuaTile::prototype and LuaGameScript::tile_prototypes.
- Added LuaEquipmentPrototype accessible from LuaEquipment::prototype and LuaGameScript::equipment_prototypes.
Scripting:
- Added LuaGuiElement::tooltip read/write - a localized tooltip for any GUI element.
- Added LuaCircuitNetwork readable off entities with circuit network connections and through control behaviors.
- Added sprite-button gui element, works the same way as button, but it can have sprite name assigned.
- Added sprite gui element, can have teh sprite name assigned/changed and has no interaction logic.
- Custom sprites can be defined in lua data definition (type = sprite, the rest is sprite definition).
- Sprite identifier can either point to custom definition from the data, or have form <type>/<id>, type can be (item, entity, recipe and technology), for example button.sprite = "item/iron-plate"
- Changed game.players[] to work with both the player index and the player name.
- Added on_gui_text_changed and on_gui_checked_state_changed events.
- LuaEntity has built_by read/write.
- Added a new entity type "electric-energy-interface" that can consume, produce, and accept energy while also allowing all of its electric network parameters to be configured runtime.
- Added flags to energy_source prototypes "render_no_network_icon" and "render_no_power_icon" to prevent rendering those icons when set.
- Added LuaGame::delete_surface. Deletes the surface passed in if the surface is deletable.
- Added invalid parameter error for data.extend function.
- Added item_pickup_distance and loot_pickup_distance to player definition.
- Added LuaItemStack::create_blueprint() - sets up a blueprint as if a player did it.
- Added LuaItemStack::build_blueprint() - builds a blueprint as if the player built it in the world.
- Added LuaSurface::deconstruct_area() - deconstructs an area as if the player did it.
- Added LuaSurface::cancel_deconstruct_area() - cancels deconstruction over an area as if the player did it.
- Added on_pre_entity_settings_pasted and on_entity_settings_pasted events that pass the source and destination entities involved.
- Added the ability to define additional_pastable_entities for an entity which allows copy-paste between that entity type and the defined destination types.
Useful in conjunction with the new copy-paste events.
- Added "robot" to the robot related events.
- Added "chunk_position" to the on_sector_scanned event.
- Added optional "player_index" to on_marked_for_deconstruction/on_canceled_deconstruction when fired due to player actions.
This field is nil when fired from from script/non player action.
- Added LuaEntity::crafting_progress/bonus_progress write.
- Added LuaForce:: item/fluid/resource/build counterparts to kill_counts.
- Added LuaFlowStatistics - used to read/write statistics data related to a given force (production, kills, etc).
- Added LuaGame::disable_replay() - disables the replay for the current save game.
- Added several player related events: on_player_cursor_stack_changed, on_player_main_inventory_changed, on_player_quickbar_inventory_changed,
on_player_tool_inventory_changed, on_player_armor_inventory_changed, on_player_ammo_inventory_changed, on_player_gun_inventory_changed,
on_player_placed_equipment, on_player_removed_equipment, on_pre_player_died, on_player_died, on_player_respawned, on_player_joined_game, on_player_left_game
- Added events for tile building: on_player_built_tile, on_player_mined_tile, on_robot_built_tile, on_robot_mined_tile
- Added a new item type "selection-tool" that fires the events on_player_selected_area and on_player_alt_selected_area.
- Construction robots will now use any available repair tool items instead of a fixed single item defined in the prototype for the robot.
- Added LuaEntity::damage_dealt/kills read/write - usable with turrets.
- Added LuaGameScript::active_mods - a table of active mod names to mod versions.
- Added LuaEquipmentGrid::get - gets the equipment at the given equipment grid position or nil if none.
- Added LuaEntity::player, returns the player connected to the character entity.
- Added LuaPlayer::get_craftable_count/begin_crafting/cancel_crafting/crafting_queue to read/write crafting information for a player.
- Various indicator and game icons are defined in the utility-sprites objects, so it is now moddable.
- Added new research options: character-crafting-speed, character-mining-speed, character-running-speed, character-build-distance, character-item-drop-distance,
character-reach-distance, character-resource-reach-distance, character-item-pickup-distance, character-loot-pickup-distance, character-inventory-slots-bonus,
deconstruction-time-to-live, character-health-bonus
- Added modifiers to the character entity that stack with the force research bonuses but are unique to the character: character_crafting_speed_modifier, character_mining_speed_modifier,
character_running_speed_modifier, character_build_distance_bonus, character_item_drop_distance_bonus, character_reach_distance_bonus, character_resource_reach_distance_bonus,
character_item_pickup_distance_bonus, character_loot_pickup_distance_bonus, quickbar_count_bonus, character_inventory_slots_bonus, character_logistic_slot_count_bonus,
character_trash_slot_count_bonus, character_maximum_following_robot_count_bonus, character_health_bonus
- Added LuaTilePrototype accessible from LuaTile::prototype and LuaGameScript::tile_prototypes.
- Added LuaEquipmentPrototype accessible from LuaEquipment::prototype and LuaGameScript::equipment_prototypes.
Scripting:
- Added LuaGuiElement::tooltip read/write - a localized tooltip for any GUI element.
- Added LuaCircuitNetwork readable off entities with circuit network connections and through control behaviors.
- Added sprite-button gui element, works the same way as button, but it can have sprite name assigned.
- Added sprite gui element, can have teh sprite name assigned/changed and has no interaction logic.
- Custom sprites can be defined in lua data definition (type = sprite, the rest is sprite definition).
- Sprite identifier can either point to custom definition from the data, or have form <type>/<id>, type can be (item, entity, recipe and technology), for example button.sprite = "item/iron-plate"
- Changed game.players[] to work with both the player index and the player name.
- Added on_gui_text_changed and on_gui_checked_state_changed events.
- LuaEntity has built_by read/write.
- Added a new entity type "electric-energy-interface" that can consume, produce, and accept energy while also allowing all of its electric network parameters to be configured runtime.
- Added flags to energy_source prototypes "render_no_network_icon" and "render_no_power_icon" to prevent rendering those icons when set.