MCPcopy Create free account
hub / github.com/crawl/crawl / run_lua

Method run_lua

crawl-ref/source/mapdef.cc:2585–2626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2583}
2584
2585string map_def::run_lua(bool run_main)
2586{
2587 dlua_set_map mset(this);
2588
2589 int err = prelude.load(dlua);
2590 if (err == E_CHUNK_LOAD_FAILURE)
2591 lua_pushnil(dlua);
2592 else if (err)
2593 return prelude.orig_error();
2594 if (!dlua.callfn("dgn_run_map", 1, 0))
2595 return rewrite_chunk_errors(dlua.error);
2596
2597 if (run_main)
2598 {
2599 // Run the map chunk to set up the vault's map grid.
2600 err = mapchunk.load(dlua);
2601 if (err == E_CHUNK_LOAD_FAILURE)
2602 lua_pushnil(dlua);
2603 else if (err)
2604 return mapchunk.orig_error();
2605 if (!dlua.callfn("dgn_run_map", 1, 0))
2606 return rewrite_chunk_errors(dlua.error);
2607
2608 // The vault may be non-rectangular with a ragged-right edge; for
2609 // transforms to work right at this point, we must pad out the right
2610 // edge with spaces, so run normalise:
2611 normalise();
2612
2613 // Run the main Lua chunk to set up the rest of the vault
2614 run_hook("pre_main");
2615 err = main.load(dlua);
2616 if (err == E_CHUNK_LOAD_FAILURE)
2617 lua_pushnil(dlua);
2618 else if (err)
2619 return main.orig_error();
2620 if (!dlua.callfn("dgn_run_map", 1, 0))
2621 return rewrite_chunk_errors(dlua.error);
2622 run_hook("post_main");
2623 }
2624
2625 return dlua.error;
2626}
2627
2628void map_def::copy_hooks_from(const map_def &other_map, const string &hook_name)
2629{

Callers 2

_resolve_map_luaFunction · 0.80
run_map_local_preludesFunction · 0.80

Calls 3

orig_errorMethod · 0.80
loadMethod · 0.45
callfnMethod · 0.45

Tested by

no test coverage detected