Sorry, I'm afraid I have no idea about the world editor objects, will forward this to the relevant people
I dont understand what a custom class means, so I only have a solution for game engine C++ scene object classes, but with the ability to preset custom fields at creation time. Let me know more info about your "custom class" if this wont suffice. If you want to create a C++ class instance but with custom field values and have a custom create group and a button in that group, in the toolbar, you can create a file in your BeamNG user data folder under the path (create it): /lua/ge/extensions/editor/myCustomObjectCreate.lua (filename can be any) Then fill it up with this code, and adjust where needed: Code: local M = {} -- our extension depends on the create object tool extension API M.dependencies = {"editor_createObjectTool"} local imgui = ui_imgui local function buildMyObject(obj) -- set various fields here, obj is the actual C++ scene object -- obj:setField("XXXXX", 0, "somevalue") end local function onEditorActivated() -- this checks if the create group was added before if not editor.getObjectCreateGroup("My Custom Classes") then -- editor.icons are all the icons that are found in the Windows->Experimental->Icons, hover icons to see name as tooltip editor.addObjectCreateGroup("My Custom Classes", editor.icons.goat, { -- here we add a create button item that will create PointLight class instances, when button pressed on toolbar and then point and click in the scene, ESC will abort editor.makeCreateObjectItem(editor.icons.wb_sunny, "PointLight", "My Title", buildMyObject) }) end end M.onEditorActivated = onEditorActivated return M It will create the group in the create toolbar, and a single button to add instances of that class with the custom fields you might set. Mind you, the new editor's APIs are still shape shifting, so some calls and methodologies might change, docs might also change, while we try to find the most optimal way to deal with things.
Yes, thank you. "Custom class" in my case meant "custom object" - you've intuited my question correctly! Another successful answer. Onwards again today - putting down markers in Hirochi Raceway to serve as a basic shakedown guide for the AI drivers. Q
Hey guys, I'm back, again confounded by the most astoundingly simple thing that I should really easily get, but just can't. Part of the problem is that I'm coding a pretty large chunk that has to be finished all together at the moment so there's really no way to try out code snippets in context. I've grabbed (I think) a table of all the current scenetree's BeamNGPointOfInterest objects (many of which I have created myself in support of my project), via this code: Code: pointsOfInterest = scenetree.findClassObjects('BeamNGPointOfInterest') I subsequently wish to iterate over the table and return a selected point of interest, chosen by matching names. Do I do that as such?: Code: local function findPOI(poiName) local retValue = nil for key, value in pairs(pointsOfInterest) do if value.name == poiName then retValue = value end end return retValue end Said another way, do I access the name of the point of interest via value.name as in my code above, or am I doing it wrong? Part of the problem is that I'm a C guy who's never coded in lua before this, and the loosely-typed nature of the language is spinning my brain around. Thanks again all - Q
That table only contains the names of the POIs and not POI objects you want. Type this into the BeamNG console to see for yourself (the "dump" function basically prints out the Lua table contents): Code: dump(scenetree.findClassObjects('BeamNGPointOfInterest')) So you can use the code below to return the POI object by its name: Code: local poi_object = scenetree.findObject(poi_name)