Archive 17/01/2023.

Where is cache defined in lua script?

ezark
-- Set font and text color
helloText:SetFont(cache:GetResource("Font", "Fonts/Anonymous Pro.ttf"), 30)
helloText.color = Color(0.0, 1.0, 0.0)

i am a starter to urho3d, i want to know where is this cache defined in the 01_HelloWorld.lua file, thanks.

Sinoid

It’s a special registered thing: See global properties on https://urho3d.github.io/documentation/1.7/_lua_script_a_p_i.html (towards the bottom)

Edit: Urho3D uses ToLua++ to generate Lua bindings so it can be a bit tricky to track down bindings, unless you’re intimate with lua (or using a fork that’s lua only) I’d strongly suggest using Angelscript, as it’s superior to C# up until C# 7.0 (7.2 is almost a C++ killer - 8.0 might deliver on promises I was told 15 years ago [default interfaces]).

ezark

ok,thank you very much. i find the cache.
but can you tell me where is this global property defined in the code? c++ or lua exactly position.

Sinoid

It’s in \pkgs\Resource\ResourceCache.pkg

Line 50:

ResourceCache* GetCache();
tolua_readonly tolua_property__get_set ResourceCache* cache;

Sorry to be so vague, but Lua is not my space - Angelscript is.

orefkov

“cache” - it is global name in script for ResourceCache subsystem.
It is equivalent to C++
GetSubsystem<ResourceCache>()
It is not defined in lua itself, it is binding to C++ code.