s25client icon indicating copy to clipboard operation
s25client copied to clipboard

[LUA] rttr:GetVersion() does not exist

Open Spikeone opened this issue 4 years ago • 5 comments

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

Spikeone avatar Nov 28 '21 21:11 Spikeone

Hm, it should I'd say.

Flamefire avatar Nov 29 '21 10:11 Flamefire

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

Spikeone avatar Nov 29 '21 11:11 Spikeone

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?

Flamefire avatar Nov 29 '21 11:11 Flamefire

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

Spikeone avatar Nov 29 '21 13:11 Spikeone

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

Flamefire avatar Nov 29 '21 14:11 Flamefire