Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/fxdata/lua/bindings/parties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ function AddTunnellerPartyToLevel(owner,party_name,spawn_location,head_for,targe
---@param location location where the party should be spawned
---@return Creature[] party_creatures list of creatures in the party, first entry is the leader
function AddPartyToLevel(owner,party_name,location) return {} end

---@param tunneler Creature the tunneller that should be sent to the location, only works on diggers that are owned by roaming player
---@param location location where the tunneller should start digging towards
function SendTunnellerToLocation(tunneler,location) end
6 changes: 6 additions & 0 deletions config/fxdata/lua/classes/Creature.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function Creature:OnDeath(action)
RegisterCreatureDeathEvent(action,self)
end

---@param location location where the tunneller should start digging towards
function Creature:tunnel_to_location(location)
SendTunnellerToLocation(self,location)
end


----functions below are implemented in C, so they have no body here

---teleports the thing to a new location
Expand Down
20 changes: 20 additions & 0 deletions src/lua_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,25 @@ static int lua_Add_party_to_level(lua_State *L)
return 1;
}

static int lua_Send_tunneller_to_location(lua_State *L)
{
struct Thing* creatng = luaL_checkThing(L, 1);
TbMapLocation destination_location = luaL_checkLocation(L, 2);

if(!thing_is_hero(creatng) || !thing_is_creature_digger(creatng))
{
SYNCERRLOG("Tried to send %s to location %d which is not a tunneller",thing_model_name(creatng),(int)spawn_location);
return 0;
}

struct Coord3d pos;
get_coords_at_location(&pos, destination_location,0);
send_tunneller_to_point(creatng, &pos);

return 0;
}


//Displaying information and affecting interface

static int lua_Display_objective(lua_State *L)
Expand Down Expand Up @@ -1954,6 +1973,7 @@ static const luaL_Reg global_methods[] = {
{"DeleteFromParty", lua_Delete_from_party },
{"AddTunnellerPartyToLevel", lua_Add_tunneller_party_to_level },
{"AddPartyToLevel", lua_Add_party_to_level },
{"SendTunnellerToLocation", lua_Send_tunneller_to_location },

//Displaying information and affecting interface
{"DisplayObjective" ,lua_Display_objective },
Expand Down