Add a Lua file for things to be automatically loaded by the engine in all contexts

This commit is contained in:
Celtic Minstrel 2017-05-04 20:17:00 -04:00
parent cef3e0d266
commit 2f15a08b78
5 changed files with 28 additions and 0 deletions

View file

@ -45,6 +45,8 @@ Version 1.13.7+dev:
for example omitting the ".lua" file extension.
* New wesnoth.create_weapon function to make a weapon that's not attached to a unit
(which could be useful for animations)
* New wesnoth.show_message function shows a simple alert dialog, possibly with a choice
* New wesnoth.alert and wesnoth.confirm functions - simple shortcuts for the above.
* Multiplayer:
* Fixed statistics being lost when reloading an MP game.
* Performance:

17
data/lua/core.lua Normal file
View file

@ -0,0 +1,17 @@
-- Note: This file is loaded automatically by the engine.
function wesnoth.alert(title, msg)
if not msg then
msg = title;
title = "";
end
wesnoth.show_message_box(title, msg, "ok", true)
end
function wesnoth.confirm(title, msg)
if not msg then
msg = title;
title = "";
end
return wesnoth.show_message_box(title, msg, "yes_no", true)
end

View file

@ -5,6 +5,7 @@
-- Steve Donovan, 2007
-- Adapted by iceiceice for wesnoth, 2014
-- Retrived from: http://lua-users.org/files/wiki_insecure/users/steved/ilua.lua
-- Note: This file is loaded automatically by the engine.
local pretty_print_limit = 20
local max_depth = 7

View file

@ -1,3 +1,4 @@
-- Note: This file is loaded automatically by the engine.
local empty_pkg = {}

View file

@ -473,6 +473,13 @@ lua_kernel_base::lua_kernel_base()
cmd_log_ << "Error: failed to load ilua.\n";
}
lua_settop(L, 0);
cmd_log_ << "Loading core...\n";
lua_pushstring(L, "lua/core.lua");
if(intf_require(L) != 1) {
cmd_log_ << "Error: Failed to load core.\n";
}
lua_settop(L, 0);
}
lua_kernel_base::~lua_kernel_base()