From 3501ca250931105c679ddf2a3b0039143f905760 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 20 Aug 2024 10:44:57 +0200 Subject: [PATCH] nilrider:: functions in user-defined levels --- rogueviz/nilrider/level.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rogueviz/nilrider/level.cpp b/rogueviz/nilrider/level.cpp index 2bf368da..551ae64d 100644 --- a/rogueviz/nilrider/level.cpp +++ b/rogueviz/nilrider/level.cpp @@ -601,7 +601,21 @@ void load_level(const string& fname) { else if(cmd == "MAP") csub->map_tiles.push_back(param); else if(cmd == "FUNCTION") { if(param == "zero") csub->surface = rot_plane; - else throw hr_exception("incorrect FUNCTION"); + else if(param == "heisenberg") csub->surface = f_heisenberg0; + else if(param == "well") csub->surface = f_rot_well; + else if(param == "longtrack") csub->surface = long_x; + else csub->surface = [param] (hyperpoint h) -> ld { + exp_parser ep; + ep.extra_params["x"] = h[0]; + ep.extra_params["y"] = h[1]; + ep.s = param; + try { + return ep.rparse(); + } + catch(hr_parse_exception&) { + return 0; + } + }; } else if(cmd == "LAYER") { auto n = new level(lev);