newbiemodder Posted February 2, 2012 Share Posted February 2, 2012 Hey all you scripters out there, I have a question. I have this script from the tutorials section on spawning placeables once, compliments of RedHawke I believe void main() { object oContainer=GetObjectByTag("spawned_container_tag"); if (oContainer==OBJECT_INVALID) { vector vContainer=Vector (0.0, 0.0, 0.0); location lContainer=Location(vContainer, 0.0); oContainer= CreateObject(OBJECT_TYPE_PLACEABLE, "container_template", lContainer); CreateItemOnObject("item_template", oContainer); } } If I wanted to expand this to spawning 3 different placeables one-time, how would I do it? Thank you. Link to comment Share on other sites More sharing options...
Qui-Gon Glenn Posted February 2, 2012 Share Posted February 2, 2012 void main() { object oContainer=GetObjectByTag("spawned_container_tag"); object oContainer2=GetObjectByTag("spawned_container_tag2"); object oContainer3=GetObjectByTag("spawned_container_tag3"); vector vContainer1=Vector (0.0, 0.0, 0.0); vector vContainer2=Vector (0.0, 0.0, 0.0); vector vContainer3=Vector (0.0, 0.0, 0.0); location lContainer1=Location(vContainer1, 0.0); location lContainer2=Location(vContainer2, 0.0); location lContainer3=Location(vContainer3, 0.0); if (!GetIsObjectValid(oContainer) && (!GetIsObjectValid(oContainer2) && (!GetIsObjectValid(oContainer3) { oContainer = CreateObject(OBJECT_TYPE_PLACEABLE, "container_template", lContainer); oContainer2 = CreateObject(OBJECT_TYPE_PLACEABLE, "container_template", lContainer2); oContainer3 = CreateObject(OBJECT_TYPE_PLACEABLE, "container_template", lContainer3); CreateItemOnObject("item_template", oContainer); CreateItemOnObject("item_template", oContainer2); CreateItemOnObject("item_template", oContainer3); } } This is an equivalent template, I think, for multiple containers. Used !GetIsObjectValid() rather than checking against OBJECT_INVALID... they check the same thing Link to comment Share on other sites More sharing options...
newbiemodder Posted February 2, 2012 Author Share Posted February 2, 2012 I'll give it a try Seems to work great, Thanks!! Link to comment Share on other sites More sharing options...
Qui-Gon Glenn Posted February 2, 2012 Share Posted February 2, 2012 Glad to help... I guess from the time stamp of your edit that you either used my edited code or figured out my little error yourself Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.