From 3a38986e4358d3a989cef881386ecc654b36fa1c Mon Sep 17 00:00:00 2001 From: zelgadis Date: Mon, 12 Nov 2007 06:09:15 +0000 Subject: Lua map markers can now be generated in C code from map_lua_marker::parse_marker() by prefixing the Lua string with "lua_mapless:" rather than "lua:". Fog machines can be created and placed from within C code via place_fog_machine(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2843 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/cloud.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crawl-ref/source/cloud.cc') diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 8306c95766..ae7b614045 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -16,6 +16,8 @@ #include "externs.h" #include "cloud.h" +#include "mapmark.h" +#include "misc.h" #include "stuff.h" #include "terrain.h" @@ -305,6 +307,42 @@ cloud_type random_smoke_type() return CLOUD_DEBUGGING; } +void place_fog_machine(fog_machine_type fm_type, cloud_type cl_type, + int x, int y, int size, int power) +{ + const char* fog_types[] = { + "geyser", + "spread", + "brownian" + }; + + try + { + char buf [160]; + sprintf(buf, "lua_mapless:fog_machine_%s(\"%s\", %d, %d)", + fog_types[fm_type], cloud_name(cl_type).c_str(), + size, power); + + map_marker *mark = map_lua_marker::parse_marker(buf, ""); + + if (mark == NULL) + { + mprf(MSGCH_DIAGNOSTICS, "Unable to parse fog machine from '%s'", + buf); + return; + } + + mark->pos = coord_def(x, y); + env.markers.add(mark); + } + catch (const std::string &err) + { + mprf(MSGCH_DIAGNOSTICS, "Error while making fog machine: %s", + err.c_str()); + } +} + + //////////////////////////////////////////////////////////////////////// // cloud_struct -- cgit v1.2.3-54-g00ecf