z_mirror/RecipeBook
git clone https://git.raiguard.me/z_mirror/RecipeBook
07fe9df
trunk
1local main_gui =require ( "scripts.gui.main" ) 2 3local allowed_types ={ 4LuaEntityPrototype =true , 5LuaEquipmentPrototype =true , 6LuaFluidPrototype =true , 7LuaItemPrototype =true , 8LuaRecipePrototype =true , 9LuaTilePrototype =true , 10} 11 12local remote_interface ={} 13 14--- Open the given page in Recipe Book. 15--- @param player_index uint 16--- @param prototype LuaEntityPrototype|LuaEquipmentPrototype|LuaFluidPrototype|LuaItemPrototype|LuaRecipePrototype|LuaTilePrototype 17--- @return boolean success 18function remote_interface . open_page ( player_index , prototype ) 19if not player_index then 20error ( "Recipe Book remote interface was not passed a player_index." ) 21end 22if type ( player_index ) ~= "number" then 23error ( "Recipe Book remote interface was passed an invalid player index." ) 24end 25if not prototype then 26error ( "Recipe Book remote interface was not passed a prototype." ) 27end 28if not prototype . valid then 29error ( "Recipe Book remote interface was passed an invalid prototype object." ) 30end 31if not allowed_types [ prototype . object_name ] then 32error ( "Recipe Book remote interface was passed an invalid prototype type." ) 33end 34local player_gui =main_gui . get_or_create ( player_index ) 35if player_gui then 36player_gui : show_page ( prototype ) 37end 38return true 39end 40 41--- Returns the current remote interface version. 42--- Mods should check against this version before calling `open_page` and abort if the version is incorrect. 43--- @return uint 44function remote_interface . version () 45return 5 46end 47 48remote . add_interface ( "RecipeBook" , remote_interface )