MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / getObject

Method getObject

src/openrct2/scripting/bindings/object/ScObjectManager.cpp:207–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207JSValue ScObjectManager::getObject(JSContext* ctx, JSValue thisVal, int argc, JSValue* argv)
208{
209 JS_UNPACK_STR(typez, ctx, argv[0]);
210 JS_UNPACK_INT32(index, ctx, argv[1]);
211 auto& objManager = GetContext()->GetObjectManager();
212
213 auto type = objectTypeFromString(typez);
214 if (type != ObjectType::none)
215 {
216 auto obj = objManager.GetLoadedObject(type, index);
217 if (obj != nullptr)
218 {
219 return CreateScObject(ctx, type, index);
220 }
221 }
222 else
223 {
224 return JS_ThrowPlainError(ctx, "Invalid object type.");
225 }
226 return JS_NULL;
227}
228
229JSValue ScObjectManager::getAllObjects(JSContext* ctx, JSValue thisVal, int argc, JSValue* argv)
230{

Callers

nothing calls this directly

Calls 3

GetContextFunction · 0.85
objectTypeFromStringFunction · 0.85
GetLoadedObjectMethod · 0.45

Tested by

no test coverage detected