You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
localjs_globalThis=panorama.open("CSGOHud") -- finds the panel CSGOHud (ID = 1), and get a reference to the globalThisprint(tostring(js_globalThis)) -- [object Object], the lua tostring method will invoke the javascript toString() method on the object-- this will iterate through the object, basically Object.keys(js_globalThis).forEach()fori,vinpanorama.pairs(js_globalThis) doprint(i.."",v,""..panorama.type(v))
end-- this will not do anything, ipairs is for arrays onlyfori,vinpanorama.ipairs(js_globalThis) doprint(i.."",v,""..panorama.type(v))
endarrtest=panorama.loadstring("return [1, false, \"test\"]") -- this compiles the js code and returns a reference to the functionprint(tostring(arrtest)) -- ()=>{return [1, false, "test"] as you can see, we have a wrapper function builtin--now we call that functionarr=arrtest()
print(tostring(arr)) -- 1,false,test again it returns an array object, so tostring() is equivalent to the javascript toString() methodprint(panorama.type(arr)) -- PersistentProxy(Array) this is indeed a js arrayprint(type(arr)) -- table, the default type() will only tell you this much, it is recommended to use panorama.type()print(panorama.type({}), panorama.type(123), panorama.type("deez nuts")) -- panorama.type() is fully compatible with the lua builtin type(), same for panorama.ipairs, panorama.pairs, panorama.len--ipairsfori,vinpanorama.ipairs(arr) doprint(i.."->" ..tostring(v).." ("..panorama.type(v)..")")
end-- [lua] 0->1 (number)-- [lua] 1->false (boolean)-- [lua] 2->test (string)print(#arr) -- 0, sadly this does not work on luajit (lua 5.1)print(panorama.len(arr)) -- 3, this worksprint(panorama.len(js_globalThis)) -- 35, this works for objects and even functions as well-- you can also access individual elements of an array or objectprint(arr[0]) -- 0 is the starting index for array access..... I know this is not the lua standard but fuck the lua standard-- example of loadrawstring, it removes the wrapper functionarrtest=panorama.loadrawstring("[1, false, \"test\"]")
-- you CANNOT use a return statement outside the scope of a function, else you will get the error Illegal return statementprint(arrtest) -- 1,false,test-- this is how you print a message to the console by calling the $.Msg function with luajs_globalThis["$"].Msg("Hello World?")
-- you can also do it this way in jspanorama.loadstring("$.Msg('Hello World!')")()
-- $ is an alias for panoramajs_globalThis.panorama.Msg("Hello World???")
-- we support the neverlose style syntax as wellpanorama.CSGOHud['$'].Msg("deeznuts1")
panorama['$'].Msg("deeznuts2")
--an example of using MyPersonaAPIlocalsteam_name=panorama.MyPersonaAPI.GetName()
print(steam_name) -- dhdjprint(type(steam_name)) -- string-- notice how the type is a lua string, rather than a PersistentProxy(String), this is because only Objects, Arrays and Functions are passed by reference, all other types are passed by value-- last thing is that panorama.open() as well as object indexing does not do any caching. so it is better tolocaljs=panorama.open()
js_MyPersonaAPI=js.MyPersonaAPIjs_MyPersonaAPI_GetName=js_MyPersonaAPI.GetNamefori=1,10dojs_MyPersonaAPI_GetName()
end-- rather thanfori=1,10dopanorama.open().MyPersonaAPI.GetName()
end-- when you have to call a js function multiple times-- the neverlose style globalThis access has a caching mechanism, however object indexing still does notprint(panorama.MyPersonaAPI.GetName()) -- panorama.MyPersonaAPI is cached, since we have already used it once, GetName is not, thus a handlescope was entered in order to access it, and another handlescope was entered in order to call it