#include <lua.h>
#include <lauxlib.h>
#include "util/numeric.h"
#include "util/serialize.h"
#include "util/string.h"
#include "log.h"
#include "common/c_converter.h"
#include "common/c_internal.h"
#include "constants.h"
#include <set>
#include <cmath>
Macros | |
#define | CHECK_TYPE(index, name, type) |
#define | CHECK_FLOAT(value, name) |
#define | CHECK_POS_COORD(index, name) CHECK_TYPE(index, "vector coordinate " name, LUA_TNUMBER) |
#define | CHECK_POS_TAB(index) CHECK_TYPE(index, "vector", LUA_TTABLE) |
Functions | |
static void | read_v3_aux (lua_State *L, int index) |
A helper which calls CUSTOM_RIDX_READ_VECTOR with the argument at the given index. | |
template<class T > | |
static bool | getv3intfield (lua_State *L, int index, const char *fieldname, T &result) |
void | push_v3f (lua_State *L, v3f p) |
void | push_v2f (lua_State *L, v2f p) |
v2s16 | read_v2s16 (lua_State *L, int index) |
void | push_v2s16 (lua_State *L, v2s16 p) |
void | push_v2s32 (lua_State *L, v2s32 p) |
void | push_v2u32 (lua_State *L, v2u32 p) |
v2s32 | read_v2s32 (lua_State *L, int index) |
v2f | read_v2f (lua_State *L, int index) |
v2f | check_v2f (lua_State *L, int index) |
v3f | read_v3f (lua_State *L, int index) |
v3f | check_v3f (lua_State *L, int index) |
v3d | read_v3d (lua_State *L, int index) |
v3d | check_v3d (lua_State *L, int index) |
void | push_ARGB8 (lua_State *L, video::SColor color) |
void | pushFloatPos (lua_State *L, v3f p) |
v3f | checkFloatPos (lua_State *L, int index) |
void | push_v3s16 (lua_State *L, v3s16 p) |
v3s16 | read_v3s16 (lua_State *L, int index) |
v3s16 | check_v3s16 (lua_State *L, int index) |
bool | read_color (lua_State *L, int index, video::SColor *color) |
video::SColor | read_ARGB8 (lua_State *L, int index) |
bool | is_color_table (lua_State *L, int index) |
aabb3f | read_aabb3f (lua_State *L, int index, f32 scale) |
void | push_aabb3f (lua_State *L, aabb3f box, f32 divisor) |
std::vector< aabb3f > | read_aabb3f_vector (lua_State *L, int index, f32 scale) |
void | push_aabb3f_vector (lua_State *L, const std::vector< aabb3f > &boxes, f32 divisor) |
size_t | read_stringlist (lua_State *L, int index, std::vector< std::string > *result) |
bool | check_field_or_nil (lua_State *L, int index, int type, const char *fieldname) |
bool | getstringfield (lua_State *L, int table, const char *fieldname, std::string &result) |
bool | getstringfield (lua_State *L, int table, const char *fieldname, std::string_view &result) |
bool | getfloatfield (lua_State *L, int table, const char *fieldname, float &result) |
bool | getboolfield (lua_State *L, int table, const char *fieldname, bool &result) |
size_t | getstringlistfield (lua_State *L, int table, const char *fieldname, std::vector< std::string > *result) |
std::string | getstringfield_default (lua_State *L, int table, const char *fieldname, const std::string &default_) |
int | getintfield_default (lua_State *L, int table, const char *fieldname, int default_) |
float | getfloatfield_default (lua_State *L, int table, const char *fieldname, float default_) |
bool | getboolfield_default (lua_State *L, int table, const char *fieldname, bool default_) |
v3s16 | getv3s16field_default (lua_State *L, int table, const char *fieldname, v3s16 default_) |
void | setstringfield (lua_State *L, int table, const char *fieldname, const std::string &value) |
void | setintfield (lua_State *L, int table, const char *fieldname, int value) |
void | setfloatfield (lua_State *L, int table, const char *fieldname, float value) |
void | setboolfield (lua_State *L, int table, const char *fieldname, bool value) |
size_t | write_array_slice_float (lua_State *L, int table_index, float *data, v3u16 data_size, v3u16 slice_offset, v3u16 slice_size) |
#define CHECK_FLOAT | ( | value, | |
name ) |
Referenced by check_v2f().
#define CHECK_POS_COORD | ( | index, | |
name ) CHECK_TYPE(index, "vector coordinate " name, LUA_TNUMBER) |
Referenced by check_v2f(), check_v3d(), and check_v3f().
#define CHECK_POS_TAB | ( | index | ) | CHECK_TYPE(index, "vector", LUA_TTABLE) |
Referenced by check_v2f(), read_v2f(), read_v2s16(), read_v2s32(), and read_v3_aux().
#define CHECK_TYPE | ( | index, | |
name, | |||
type ) |
Referenced by read_ARGB8().
bool check_field_or_nil | ( | lua_State * | L, |
int | index, | ||
int | type, | ||
const char * | fieldname ) |
References errorstream, hash(), murmur_hash_64_ua(), and script_get_backtrace().
Referenced by getboolfield(), getfloatfield(), getintfield(), getstringfield(), read_content_features(), and read_wear_bar_params().
v2f check_v2f | ( | lua_State * | L, |
int | index ) |
References CHECK_FLOAT, CHECK_POS_COORD, CHECK_POS_TAB, and p().
Referenced by LuaParticleParams::readLuaValue(), and LuaHelper::readParam().
v3d check_v3d | ( | lua_State * | L, |
int | index ) |
References CHECK_POS_COORD, and read_v3_aux().
Referenced by check_v3s16().
v3f check_v3f | ( | lua_State * | L, |
int | index ) |
References CHECK_POS_COORD, and read_v3_aux().
Referenced by checkFloatPos(), ModApiParticles::l_add_particle(), ModApiParticlesLocal::l_add_particle(), ModApiParticles::l_add_particlespawner(), LuaPerlinNoiseMap::l_calc_3d_map(), LuaPerlinNoise::l_get_3d(), LuaPerlinNoiseMap::l_get_3d_map(), LuaPerlinNoiseMap::l_get_3d_map_flat(), ObjectRef::l_set_bone_override(), ObjectRef::l_set_bone_position(), ObjectRef::l_set_rotation(), read_item_definition(), LuaParticleParams::readLuaValue(), and LuaHelper::readParam().
v3s16 check_v3s16 | ( | lua_State * | L, |
int | index ) |
References check_v3d(), and doubleToInt().
Referenced by LuaVoxelManip::l_calc_lighting(), ModApiEnv::l_compare_block_status(), ModApiMapgen::l_create_schematic(), ModApiEnv::l_find_nodes_with_meta(), ModApiMapgen::l_generate_decorations(), ModApiMapgen::l_generate_ores(), LuaAreaStore::l_get_areas_for_pos(), LuaAreaStore::l_get_areas_in_area(), ModApiInventory::l_get_inventory(), LuaVoxelManip::l_get_node_at(), LuaAreaStore::l_insert_area(), ModApiEnv::l_load_area(), ModApiMapgen::l_place_schematic(), ModApiMapgen::l_place_schematic_on_vmanip(), LuaVoxelManip::l_read_from_map(), LuaVoxelManip::l_set_lighting(), LuaVoxelManip::l_set_node_at(), and read_schematic_def().
v3f checkFloatPos | ( | lua_State * | L, |
int | index ) |
References BS, and check_v3f().
Referenced by LuaRaycast::create_object(), ModApiEnv::l_add_entity(), ObjectRef::l_add_pos(), ObjectRef::l_add_velocity(), ModApiEnv::l_get_objects_inside_radius(), ModApiEnv::l_line_of_sight(), ObjectRef::l_move_to(), ObjectRef::l_set_acceleration(), ObjectRef::l_set_pos(), and ObjectRef::l_set_velocity().
bool getboolfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
bool & | result ) |
References check_field_or_nil(), and table.
Referenced by getboolfield_default(), ModApiServer::l_dynamic_add_media(), ObjectRef::l_hud_set_flags(), ObjectRef::l_set_physics_override(), ModApiClientSound::l_sound_play(), read_content_features(), read_flags_table(), read_item_definition(), read_object_properties(), read_server_sound_params(), read_tree_def(), and ScriptApiEnv::readABMs().
bool getboolfield_default | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
bool | default_ ) |
References getboolfield(), and table.
Referenced by ModApiParticles::l_add_particle(), ModApiParticlesLocal::l_add_particle(), ModApiParticles::l_add_particlespawner(), ModApiParticlesLocal::l_add_particlespawner(), ModApiMapgen::l_serialize_schematic(), LuaAreaStore::l_set_cache_params(), ObjectRef::l_set_flags(), ObjectRef::l_set_moon(), ObjectRef::l_set_sky(), ObjectRef::l_set_stars(), ObjectRef::l_set_sun(), ModApiHttp::read_http_fetch_request(), read_schematic_def(), read_tiledef(), and ScriptApiEnv::readLBMs().
bool getfloatfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
float & | result ) |
References check_field_or_nil(), and table.
Referenced by getfloatfield_default(), ModApiMapgen::l_register_ore(), ObjectRef::l_set_lighting(), ObjectRef::l_set_physics_override(), ModApiClientSound::l_sound_play(), read_animation_definition(), read_content_features(), read_noiseparams(), read_object_properties(), read_server_sound_params(), read_simplesoundspec(), read_tool_capabilities(), and ScriptApiEnv::readABMs().
float getfloatfield_default | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
float | default_ ) |
References getfloatfield(), and table.
Referenced by ModApiParticles::l_add_particle(), ModApiParticlesLocal::l_add_particle(), ModApiParticles::l_add_particlespawner(), ModApiParticlesLocal::l_add_particlespawner(), ModApiCraft::l_register_craft(), ModApiMapgen::l_register_decoration(), ModApiMapgen::l_register_ore(), ObjectRef::l_set_clouds(), ObjectRef::l_set_lighting(), ObjectRef::l_set_moon(), ObjectRef::l_set_sky(), ObjectRef::l_set_stars(), ObjectRef::l_set_sun(), read_animation_definition(), read_biome_def(), read_item_definition(), and read_server_sound_params().
int getintfield_default | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
int | default_ ) |
References getintfield(), and table.
Referenced by ModApiParticles::l_add_particle(), ModApiParticlesLocal::l_add_particle(), ModApiParticles::l_add_particlespawner(), ModApiParticlesLocal::l_add_particlespawner(), ModApiMapgen::l_create_schematic(), ModApiMapgen::l_register_decoration(), ModApiMapgen::l_register_ore(), ModApiMapgen::l_serialize_schematic(), LuaAreaStore::l_set_cache_params(), LuaVoxelManip::l_set_lighting(), ObjectRef::l_set_minimap_modes(), ObjectRef::l_set_sky(), ObjectRef::l_set_stars(), read_animation_definition(), read_biome_def(), read_content_features(), read_deco_simple(), read_hud_element(), read_item(), read_item_definition(), read_schematic_def(), and read_tiledef().
bool getstringfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
std::string & | result ) |
References getstringfield(), and table.
Referenced by ScriptApiServer::getAuth(), getstringfield(), getstringfield_default(), ModApiAuth::l_auth_create(), ModApiAuth::l_auth_save(), ModApiServer::l_dynamic_add_media(), read_content_features(), ModApiHttp::read_http_fetch_request(), read_hud_element(), read_item_definition(), read_object_properties(), read_schematic_def(), read_server_sound_params(), read_simplesoundspec(), read_tiledef(), read_tree_def(), and ScriptApiEnv::readLBMs().
bool getstringfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
std::string_view & | result ) |
std::string getstringfield_default | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
const std::string & | default_ ) |
References getstringfield(), and table.
Referenced by getenumfield(), ModApiParticles::l_add_particle(), ModApiParticles::l_add_particlespawner(), ModApiCraft::l_clear_craft(), ModApiCraft::l_get_craft_result(), ModApiMapgen::l_read_schematic(), ModApiCraft::l_register_craft(), ModApiMapgen::l_register_decoration(), ModApiMapgen::l_register_ore(), ObjectRef::l_set_minimap_modes(), ObjectRef::l_set_moon(), ObjectRef::l_set_nametag_attributes(), ObjectRef::l_set_sun(), read_biome_def(), ModApiHttp::read_http_fetch_request(), read_hud_element(), read_item(), and ScriptApiBase::setOriginFromTableRaw().
size_t getstringlistfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
std::vector< std::string > * | result ) |
References read_stringlist(), and table.
Referenced by ModApiMapgen::l_register_decoration(), ModApiMapgen::l_register_ore(), read_biome_def(), and read_deco_simple().
|
static |
References getintfield().
Referenced by getv3s16field_default().
References getv3intfield(), and table.
Referenced by read_biome_def().
bool is_color_table | ( | lua_State * | L, |
int | index ) |
References is_color_table().
Referenced by is_color_table(), and ObjectRef::l_set_sky().
void push_aabb3f | ( | lua_State * | L, |
aabb3f | box, | ||
f32 | divisor ) |
Referenced by push_aabb3f_vector(), push_nodebox(), and push_object_properties().
void push_aabb3f_vector | ( | lua_State * | L, |
const std::vector< aabb3f > & | boxes, | ||
f32 | divisor ) |
References push_aabb3f().
Referenced by ModApiEnv::l_get_node_boxes(), and push_nodebox().
void push_ARGB8 | ( | lua_State * | L, |
video::SColor | color ) |
Referenced by ModApiUtil::l_colorspec_to_table(), ObjectRef::l_get_clouds(), ObjectRef::l_get_lighting(), ObjectRef::l_get_nametag_attributes(), ObjectRef::l_get_sky(), ObjectRef::l_get_stars(), push_content_features(), push_item_definition_full(), push_object_properties(), push_palette(), push_sky_color(), and push_wear_bar_params().
void push_v2f | ( | lua_State * | L, |
v2f | p ) |
References p().
Referenced by ObjectRef::l_get_animation(), ObjectRef::l_get_local_animation(), ModApiServer::l_get_player_window_information(), ModApiMainMenu::l_get_window_info(), and push_hud_element().
void push_v2s16 | ( | lua_State * | L, |
v2s16 | p ) |
References p().
Referenced by push_object_properties().
void push_v2s32 | ( | lua_State * | L, |
v2s32 | p ) |
References p().
Referenced by push_hud_element().
void push_v2u32 | ( | lua_State * | L, |
v2u32 | p ) |
References p().
Referenced by ModApiServer::l_get_player_window_information(), and ModApiMainMenu::l_get_window_info().
void push_v3f | ( | lua_State * | L, |
v3f | p ) |
References CUSTOM_RIDX_PUSH_VECTOR, and p().
Referenced by ObjectRef::l_get_attach(), ObjectRef::l_get_bone_position(), ObjectRef::l_get_eye_offset(), LuaLocalPlayer::l_get_last_pos(), LuaLocalPlayer::l_get_last_velocity(), LuaCamera::l_get_look_dir(), ObjectRef::l_get_look_dir(), LuaCamera::l_get_offset(), LuaCamera::l_get_pos(), LuaLocalPlayer::l_get_pos(), ObjectRef::l_get_pos(), ObjectRef::l_get_rotation(), LuaLocalPlayer::l_get_velocity(), ObjectRef::l_get_velocity(), ScriptApiEntity::luaentity_Punch(), ScriptApiPlayer::on_punchplayer(), push_bone_override(), push_collision_move_result(), push_hud_element(), push_item_definition_full(), push_noiseparams(), push_object_properties(), push_pointed_thing(), and pushFloatPos().
void push_v3s16 | ( | lua_State * | L, |
v3s16 | p ) |
References CUSTOM_RIDX_PUSH_VECTOR, and p().
Referenced by ScriptApiEnv::check_for_falling(), ScriptApiEnv::environment_OnGenerated(), ModApiEnvBase::findNodeNear(), ModApiEnvBase::findNodesInArea(), ModApiEnvBase::findNodesInAreaUnderAir(), ModApiEnv::l_find_nodes_with_meta(), ModApiEnv::l_find_path(), LuaVoxelManip::l_get_emerged_area(), InvRef::l_get_location(), ModApiMapgen::l_get_mapgen_edges(), ModApiMapgen::l_get_mapgen_object(), LuaMinimap::l_get_pos(), ModApiEnv::l_line_of_sight(), LuaVoxelManip::l_read_from_map(), ModApiMapgen::l_read_schematic(), ModApiRollback::l_rollback_get_node_actions(), ScriptApiNode::node_after_destruct(), ScriptApiNode::node_on_construct(), ScriptApiNode::node_on_destruct(), ScriptApiNode::node_on_dig(), ScriptApiNode::node_on_flood(), ScriptApiNode::node_on_punch(), ScriptApiNode::node_on_receive_fields(), ScriptApiNode::node_on_timer(), ScriptApiNodemeta::nodemeta_inventory_AllowMove(), ScriptApiNodemeta::nodemeta_inventory_AllowPut(), ScriptApiNodemeta::nodemeta_inventory_AllowTake(), ScriptApiNodemeta::nodemeta_inventory_OnMove(), ScriptApiNodemeta::nodemeta_inventory_OnPut(), ScriptApiNodemeta::nodemeta_inventory_OnTake(), ScriptApiClient::on_dignode(), ScriptApiEnv::on_emerge_area_completion(), ScriptApiMapgen::on_generated(), ScriptApiEnv::on_liquid_transformed(), ScriptApiClient::on_punchnode(), push_area(), push_collision_move_result(), push_pointed_thing(), ScriptApiBase::pushPlayerHPChangeReason(), ScriptApiEnv::triggerABM(), and ScriptApiEnv::triggerLBM().
void pushFloatPos | ( | lua_State * | L, |
v3f | p ) |
References BS, p(), and push_v3f().
Referenced by ScriptApiItem::item_OnDrop(), ObjectRef::l_get_acceleration(), and ObjectRef::l_get_velocity().
aabb3f read_aabb3f | ( | lua_State * | L, |
int | index, | ||
f32 | scale ) |
Referenced by read_aabb3f_vector(), and read_object_properties().
std::vector< aabb3f > read_aabb3f_vector | ( | lua_State * | L, |
int | index, | ||
f32 | scale ) |
video::SColor read_ARGB8 | ( | lua_State * | L, |
int | index ) |
bool read_color | ( | lua_State * | L, |
int | index, | ||
video::SColor * | color ) |
References parseColorString(), and read_ARGB8().
Referenced by ModApiUtil::l_colorspec_to_bytes(), ModApiUtil::l_colorspec_to_colorstring(), ModApiUtil::l_colorspec_to_table(), ObjectRef::l_set_clouds(), ObjectRef::l_set_lighting(), ObjectRef::l_set_nametag_attributes(), ObjectRef::l_set_sky(), ObjectRef::l_set_stars(), read_content_features(), read_item_definition(), read_object_properties(), read_tiledef(), and read_wear_bar_params().
size_t read_stringlist | ( | lua_State * | L, |
int | index, | ||
std::vector< std::string > * | result ) |
v2f read_v2f | ( | lua_State * | L, |
int | index ) |
References CHECK_POS_TAB, and p().
Referenced by ObjectRef::l_set_local_animation(), read_hud_change(), read_hud_element(), and read_object_properties().
v2s16 read_v2s16 | ( | lua_State * | L, |
int | index ) |
References CHECK_POS_TAB, and p().
Referenced by read_object_properties(), and LuaHelper::readParam().
v2s32 read_v2s32 | ( | lua_State * | L, |
int | index ) |
References CHECK_POS_TAB, and p().
Referenced by read_hud_change(), and read_hud_element().
|
static |
A helper which calls CUSTOM_RIDX_READ_VECTOR with the argument at the given index.
References CHECK_POS_TAB, and CUSTOM_RIDX_READ_VECTOR.
Referenced by check_v3d(), check_v3f(), read_v3d(), and read_v3f().
v3d read_v3d | ( | lua_State * | L, |
int | index ) |
References read_v3_aux().
Referenced by read_v3s16().
v3f read_v3f | ( | lua_State * | L, |
int | index ) |
References read_v3_aux().
Referenced by ModApiEnv::l_get_objects_in_area(), ModApiClientSound::l_sound_play(), read_hud_change(), read_hud_element(), read_noiseparams(), and read_server_sound_params().
v3s16 read_v3s16 | ( | lua_State * | L, |
int | index ) |
References doubleToInt(), and read_v3d().
Referenced by LuaPerlinNoiseMap::create_object(), ModApiEnv::l_add_node_level(), ModApiEnvVM::l_add_node_level(), ModApiEnv::l_bulk_set_node(), ModApiEnv::l_bulk_swap_node(), ModApiEnv::l_delete_area(), ModApiEnv::l_dig_node(), ModApiEnv::l_emerge_area(), ModApiEnv::l_find_node_near(), ModApiEnvVM::l_find_node_near(), ModApiEnv::l_find_nodes_in_area(), ModApiEnvVM::l_find_nodes_in_area(), ModApiEnv::l_find_nodes_in_area_under_air(), ModApiEnvVM::l_find_nodes_in_area_under_air(), ModApiEnv::l_find_path(), ModApiEnv::l_fix_light(), ModApiEnv::l_forceload_block(), ModApiEnv::l_forceload_free_block(), ModApiMapgen::l_get_biome_data(), ModApiMapgen::l_get_heat(), ModApiMapgen::l_get_humidity(), LuaPerlinNoiseMap::l_get_map_slice(), ModApiClient::l_get_meta(), ModApiEnv::l_get_meta(), ModApiEnv::l_get_natural_light(), ModApiEnv::l_get_node_boxes(), ModApiEnv::l_get_node_level(), ModApiEnvVM::l_get_node_level(), ModApiEnv::l_get_node_light(), ModApiEnv::l_get_node_max_level(), ModApiEnvVM::l_get_node_max_level(), ModApiClient::l_get_node_or_nil(), ModApiEnvVM::l_get_node_or_nil(), ModApiEnv::l_get_node_timer(), ModApiEnv::l_get_perlin_map(), ModApiEnv::l_place_node(), ModApiEnv::l_punch_node(), ModApiEnv::l_remove_node(), ModApiRollback::l_rollback_get_node_actions(), ObjectRef::l_send_mapblock(), ModApiEnv::l_set_node(), ModApiEnv::l_set_node_level(), ModApiEnvVM::l_set_node_level(), LuaMinimap::l_set_pos(), ModApiEnv::l_spawn_tree(), ModApiEnvVM::l_spawn_tree(), ModApiEnv::l_swap_node(), and ModApiEnv::l_transforming_liquid_add().
void setboolfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
bool | value ) |
References table.
Referenced by ModApiClient::l_get_csm_restrictions(), push_collision_move_result(), push_dig_params(), ModApiHttp::push_http_fetch_result(), and ScriptApiMainMenu::setMainMenuData().
void setfloatfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
float | value ) |
References table.
Referenced by push_dig_params(), push_noiseparams(), and push_tool_capabilities().
void setintfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
int | value ) |
References table.
Referenced by ModApiCraft::l_get_craft_recipe(), ModApiCraft::l_get_craft_result(), push_craft_recipe(), push_dig_params(), push_hit_params(), ModApiHttp::push_http_fetch_result(), push_noiseparams(), and push_tool_capabilities().
void setstringfield | ( | lua_State * | L, |
int | table, | ||
const char * | fieldname, | ||
const std::string & | value ) |
References table.
Referenced by ModApiServer::l_get_game_info(), ModApiHttp::push_http_fetch_result(), and push_wear_bar_params().
size_t write_array_slice_float | ( | lua_State * | L, |
int | table_index, | ||
float * | data, | ||
v3u16 | data_size, | ||
v3u16 | slice_offset, | ||
v3u16 | slice_size ) |
References MYMIN.
Referenced by LuaPerlinNoiseMap::l_get_map_slice().