forked from github/server
lua functions:
message_unit message_region message_faction
This commit is contained in:
parent
99a5f4d525
commit
d8cff1f61f
|
@ -1780,7 +1780,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
void
|
||||
deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
||||
{
|
||||
if (!cansee(f, r, u, 0)) {
|
||||
|
|
|
@ -32,10 +32,10 @@ void demographics(void);
|
|||
void last_orders(void);
|
||||
void find_address(void);
|
||||
void update_guards(void);
|
||||
extern void deliverMail(struct faction * f, struct region * r, struct unit * u, const char *s, struct unit * receiver);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
#include "resolve.h"
|
||||
|
||||
void processorders(void);
|
||||
extern attrib_type at_germs;
|
||||
|
||||
|
|
|
@ -147,6 +147,25 @@ update_subscriptions(void)
|
|||
fclose(F);
|
||||
}
|
||||
|
||||
static void
|
||||
message_unit(unit& sender, unit& target, const char * str)
|
||||
{
|
||||
deliverMail(target.faction, sender.region, &sender, str, &target);
|
||||
}
|
||||
|
||||
static void
|
||||
message_faction(unit& sender, faction& target, const char * str)
|
||||
{
|
||||
deliverMail(&target, sender.region, &sender, str, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
message_region(unit& sender, const char * str)
|
||||
{
|
||||
sprintf(buf, "von %s: '%s'", unitname(&sender), str);
|
||||
addmessage(sender.region, 0, buf, MSG_MESSAGE, ML_IMPORTANT);
|
||||
}
|
||||
|
||||
static void
|
||||
lua_learnskill(unit& u, const char * skname, float chances)
|
||||
{
|
||||
|
@ -266,6 +285,10 @@ bind_gamecode(lua_State * L)
|
|||
def("write_report", &lua_writereport),
|
||||
def("update_guards", &update_guards),
|
||||
|
||||
def("message_unit", &message_unit),
|
||||
def("message_faction", &message_faction),
|
||||
def("message_region", &message_region),
|
||||
|
||||
/* scripted monsters */
|
||||
def("spawn_braineaters", &spawn_braineaters),
|
||||
def("spawn_undead", &spawn_undead),
|
||||
|
|
|
@ -161,6 +161,9 @@ function test_handler()
|
|||
print(u)
|
||||
print(u2)
|
||||
print(str)
|
||||
message_unit(u, u2, "thanks unit, i got your message: " .. str)
|
||||
message_faction(u, u2.faction, "thanks faction, i got your message: " .. str)
|
||||
message_region(u, "thanks region, i got your message: " .. str)
|
||||
end
|
||||
|
||||
plain = terraform(0, 0, "plain")
|
||||
|
@ -373,20 +376,7 @@ function run_scripts()
|
|||
end
|
||||
end
|
||||
|
||||
-- test_movement()
|
||||
-- test_fail()
|
||||
-- test_handler()
|
||||
-- test_parser()
|
||||
-- test_monsters()
|
||||
-- test_combat()
|
||||
-- test_rewards()
|
||||
-- test_give()
|
||||
-- test_write()
|
||||
|
||||
-- test_sail()
|
||||
-- write_game("../testg.txt")
|
||||
-- read_game("../testg.txt")
|
||||
|
||||
function test_moving()
|
||||
test_movement()
|
||||
run_scripts()
|
||||
process_orders()
|
||||
|
@ -417,3 +407,24 @@ end
|
|||
if astra.region ~= r4 then
|
||||
print "ERROR: Astraleinheit konnte Wirbel nicht benutzen"
|
||||
end
|
||||
end
|
||||
|
||||
-- test_movement()
|
||||
-- test_fail()
|
||||
test_handler()
|
||||
-- test_parser()
|
||||
-- test_monsters()
|
||||
-- test_combat()
|
||||
-- test_rewards()
|
||||
-- test_give()
|
||||
-- test_write()
|
||||
|
||||
-- test_sail()
|
||||
-- write_game("../testg.txt")
|
||||
-- read_game("../testg.txt")
|
||||
|
||||
run_scripts()
|
||||
process_orders()
|
||||
write_reports()
|
||||
|
||||
-- test_moving()
|
||||
|
|
Loading…
Reference in New Issue