Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
476 stars 75 forks source link

[LUA] rttr:GetVersion() does not exist #1462

Open Spikeone opened 2 years ago

Spikeone commented 2 years ago

The documentation references rttr:GetVersion() two times, but this function seems no longer to exist

https://github.com/Return-To-The-Roots/s25client/blob/master/doc/lua/methods.md#base-functions-callable-in-settings-and-game-mode

Flamefire commented 2 years ago

Hm, it should I'd say.

Spikeone commented 2 years ago

I get

Lua error: [string "function getRequiredLuaVersion()..."]:20: attempt to call method 'GetVersion' (a nil value)

When using this simple script:

function getRequiredLuaVersion()
    return 1.3
end

function onSettingsReady()
    rttr:Log("Version" ..rttr:GetVersion())
end

(Linenumber in my output is from a larger script, but the shown example is a minimalised version)

EDIT: Ah I see, it's missing in the void LuaInterfaceGameBase::Register(kaguya::State& state) isnt it? There is a GetFeatureLevel but GetVersion is missing

Flamefire commented 2 years ago

No I meant we should have it. But I think we replaced it by GetFeatureLevel. The idea is: getRequiredLuaVersion should return an integer(!) which is then checked against the major version: https://github.com/Return-To-The-Roots/s25client/blob/4ce6199a77ebb44b5b14cdc23c0e0a19e41c77ca/libs/s25main/lua/LuaInterfaceGameBase.cpp#L44 as a change there means incompatible changes GetFeatureLevel can then be used to check if a function or similar is available already.

Do you get what I mean? Do you mind updating the docs?

Spikeone commented 2 years ago

Yeah, I get the idea - can do, but you know that means sooner or later I will have a problem with cmake and ask you :D

Flamefire commented 2 years ago

You should only update the docs. So no CMake involved :D