2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2013-01-23 18:32:02 +01:00
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-01-23 18:32:02 +01:00
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
#include "cpp_api/s_base.h"
|
|
|
|
#include "irr_v3d.h"
|
2021-07-09 09:08:40 -04:00
|
|
|
#include "mapnode.h"
|
2022-09-03 22:05:07 -04:00
|
|
|
#include <unordered_set>
|
2021-07-09 09:08:40 -04:00
|
|
|
#include <vector>
|
2013-01-23 18:32:02 +01:00
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
class ServerEnvironment;
|
2024-08-11 14:54:02 +02:00
|
|
|
class MapBlock;
|
2015-10-30 02:48:37 -04:00
|
|
|
struct ScriptCallbackState;
|
2013-01-23 18:32:02 +01:00
|
|
|
|
2016-03-07 19:34:48 +01:00
|
|
|
class ScriptApiEnv : virtual public ScriptApiBase
|
|
|
|
{
|
2013-05-25 00:51:02 +02:00
|
|
|
public:
|
2015-10-30 02:48:37 -04:00
|
|
|
// Called on environment step
|
2013-05-25 00:51:02 +02:00
|
|
|
void environment_Step(float dtime);
|
|
|
|
|
2015-10-30 02:48:37 -04:00
|
|
|
// Called after generating a piece of map
|
|
|
|
void environment_OnGenerated(v3s16 minp, v3s16 maxp, u32 blockseed);
|
|
|
|
|
|
|
|
// Called on player event
|
2016-03-07 19:34:48 +01:00
|
|
|
void player_event(ServerActiveObject *player, const std::string &type);
|
2015-10-30 02:48:37 -04:00
|
|
|
|
|
|
|
// Called after emerge of a block queued from core.emerge_area()
|
|
|
|
void on_emerge_area_completion(v3s16 blockpos, int action,
|
|
|
|
ScriptCallbackState *state);
|
2014-04-28 23:41:27 +02:00
|
|
|
|
2022-10-18 18:03:05 -04:00
|
|
|
void check_for_falling(v3s16 p);
|
|
|
|
|
2021-07-09 09:08:40 -04:00
|
|
|
// Called after liquid transform changes
|
|
|
|
void on_liquid_transformed(const std::vector<std::pair<v3s16, MapNode>> &list);
|
|
|
|
|
2022-09-03 22:05:07 -04:00
|
|
|
// Called after mapblock changes
|
|
|
|
void on_mapblocks_changed(const std::unordered_set<v3s16> &set);
|
|
|
|
|
|
|
|
// Determines whether there are any on_mapblocks_changed callbacks
|
|
|
|
bool has_on_mapblocks_changed();
|
|
|
|
|
2025-04-09 20:27:26 +02:00
|
|
|
// Calll Lua callback for block
|
|
|
|
void block_callback(const v3s16 blockpos, ScriptCallbackState *state);
|
|
|
|
|
2024-08-11 13:34:03 +02:00
|
|
|
// Initializes environment and loads some definitions from Lua
|
2013-05-25 00:51:02 +02:00
|
|
|
void initializeEnvironment(ServerEnvironment *env);
|
2024-08-11 13:34:03 +02:00
|
|
|
|
|
|
|
void triggerABM(int id, v3s16 p, MapNode n,
|
|
|
|
u32 active_object_count, u32 active_object_count_wider);
|
|
|
|
|
2024-08-11 14:54:02 +02:00
|
|
|
void triggerLBM(int id, MapBlock *block,
|
|
|
|
const std::unordered_set<v3s16> &positions, float dtime_s);
|
2024-08-11 13:34:03 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void readABMs();
|
|
|
|
|
|
|
|
void readLBMs();
|
|
|
|
|
|
|
|
// Reads a single or a list of node names into a vector
|
|
|
|
static bool read_nodenames(lua_State *L, int idx, std::vector<std::string> &to);
|
2013-05-25 00:51:02 +02:00
|
|
|
};
|