| 2671 | } |
| 2672 | |
| 2673 | bool map_def::test_lua_boolchunk(dlua_chunk &chunk, bool defval, |
| 2674 | bool die_on_lua_error) |
| 2675 | { |
| 2676 | bool result = defval; |
| 2677 | dlua_set_map mset(this); |
| 2678 | |
| 2679 | int err = chunk.load(dlua); |
| 2680 | if (err == E_CHUNK_LOAD_FAILURE) |
| 2681 | return result; |
| 2682 | else if (err) |
| 2683 | { |
| 2684 | if (die_on_lua_error) |
| 2685 | end(1, false, "Lua error: %s", chunk.orig_error().c_str()); |
| 2686 | else |
| 2687 | mprf(MSGCH_ERROR, "Lua error: %s", chunk.orig_error().c_str()); |
| 2688 | return result; |
| 2689 | } |
| 2690 | if (dlua.callfn("dgn_run_map", 1, 1)) |
| 2691 | dlua.fnreturns(">b", &result); |
| 2692 | else |
| 2693 | { |
| 2694 | if (die_on_lua_error) |
| 2695 | { |
| 2696 | end(1, false, "Lua error: %s", |
| 2697 | rewrite_chunk_errors(dlua.error).c_str()); |
| 2698 | } |
| 2699 | else |
| 2700 | { |
| 2701 | mprf(MSGCH_ERROR, "Lua error: %s", |
| 2702 | rewrite_chunk_errors(dlua.error).c_str()); |
| 2703 | } |
| 2704 | } |
| 2705 | return result; |
| 2706 | } |
| 2707 | |
| 2708 | bool map_def::test_lua_validate(bool croak) |
| 2709 | { |