HollownessDevoured Posted April 20, 2023 Share Posted April 20, 2023 (edited) I am still trying to expand my script knowledge. This time by placing objects. I have successfully placed the object with PRCSCR/script but:it is not showing where (I thought) I specified the position/location (on a table, it is on the floor) and;it is not interactive, despite it having the sparkly/can be highlighted. This tutorial: http://www.datoolset.net/wiki/PRCSCR_Script_Templates#Adding_a_placeable_into_an_existing_Area My current script: void main() { object oMainControlled = GetMainControlled(); object oJar = UT_GetNearestObjectByTag(oMainControlled, TAL_IP_GENIP_JAR_3); //DisplayFloatyMessage(oMainControlled, "storage script working", FLOATY_MESSAGE, 16777215, 30.0); if (!IsObjectValid(oJar)) { location lSpawn = Location(GetArea(oMainControlled), Vector(-47.7354,6.94977,0.733148), 0.0); CreateObject(OBJECT_TYPE_PLACEABLE, TAL_RESOURCE_IP_GENIP_JAR_3, lSpawn); //DisplayFloatyMessage(oMainControlled, "storage chest created", FLOATY_MESSAGE, 16777215, 30.0); } } Edited April 20, 2023 by HollownessDevoured Link to comment Share on other sites More sharing options...
Pasquale1223 Posted April 20, 2023 Share Posted April 20, 2023 Congrats! You've created a PRCSCR script and successfully used it to create an object. The z portion of the vector determines the height. Remember, the world is 3D, so you need to specify all 3 dimensions, and z is height. You might need to set the object interactive, but first you'll need to get a reference to it. You can do that when you create it by getting the reference when you use the CreateObject function, like so: oJar = CreateObject(OBJECT_TYPE_PLACEABLE, TAL_RESOURCE_IP_GENIP_JAR_3, lSpawn); Then just set it interactive: SetObjectInteractive(oJar,TRUE); Link to comment Share on other sites More sharing options...
HollownessDevoured Posted April 20, 2023 Author Share Posted April 20, 2023 Congrats! You've created a PRCSCR script and successfully used it to create an object. The z portion of the vector determines the height. Remember, the world is 3D, so you need to specify all 3 dimensions, and z is height. You might need to set the object interactive, but first you'll need to get a reference to it. You can do that when you create it by getting the reference when you use the CreateObject function, like so: oJar = CreateObject(OBJECT_TYPE_PLACEABLE, TAL_RESOURCE_IP_GENIP_JAR_3, lSpawn); Then just set it interactive: SetObjectInteractive(oJar,TRUE); Not gonna lie, I am pretty proud of myself; it is a first time :D I assumed it was, and my coordinates the "0.733148", I assume 0.0 is floor, -1 under above 0.0 higher. Maybe when I was placing in the area map to get coordinates, it was giving me a false visual. I'll play with it. And I must have placed your suggested code in the wrong area because now the jar is invisible but if I highlight I can see the name "Jar". Link to comment Share on other sites More sharing options...
HollownessDevoured Posted April 20, 2023 Author Share Posted April 20, 2023 Wait, no. I think I did something. Cause none of my versions are working atm. Brb. Link to comment Share on other sites More sharing options...
HollownessDevoured Posted April 20, 2023 Author Share Posted April 20, 2023 Ok, I think I know what it is. When I try to place on a table or surface it is erroring out. Firstly by showing under the table/surface, then secondly making it not possible to interact with. This is odd considering the are multiple placeables on surfaces that work in the game, but maybe because they are added via area map? Because I tried over again before your suggested code, but put it out in the open, and it works. but... it is on the floor. Link to comment Share on other sites More sharing options...
Shanamah Posted April 20, 2023 Share Posted April 20, 2023 The game is very particular about what is a "safe" position for spawning objects, and will automatically move things to the nearest safe position. SetPosition can be used to move things back to "unsafe" positions.http://www.datoolset.net/wiki/SetPosition Link to comment Share on other sites More sharing options...
Pasquale1223 Posted April 20, 2023 Share Posted April 20, 2023 As for where to put the code, I expected you'd just put "oJar = " in front of the CreateObject statement as you have it, and the SetObjectInteractive statement immediately after the CreateObject. As for the rest - I've never worked with adding objects to an existing area, so I'm afraid I can't be much help. I'm guessing you're running into object collisions. If the level designers put a table in a level they did not expect to have an interactive object on it, that table may not have the correct properties to allow you to set stuff on it and be able to interact with them. It's... complicated, but as far as the game engine is concerned, anything else you try to put in that space may be unreachable as far as the game is concerned because the boundaries of the bigger object (the table) would not allow you to get to it unless you changed its properties. Link to comment Share on other sites More sharing options...
HollownessDevoured Posted April 20, 2023 Author Share Posted April 20, 2023 Thank you for all the insight. There are some things to ponder, and I do think it is something between "safe positions"/"object collisions". Link to comment Share on other sites More sharing options...
Recommended Posts