Author Topic: Spawn and despawning placeable.... some help please?  (Read 394 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Spawn and despawning placeable.... some help please?
« on: April 15, 2015, 07:12:10 pm »


               

Well here I am again with another request for help!


 


Okay here is what I am working on (probably wrote it all wrong but hey that is why I am learning right?) 


 


I want to create an unique item that can spawn an placeable by clicking on a location nearby the character (this case a campfire called Resting allowed as the resref) 


 


 

{

object oPC;

 

if (!GetIsPC(GetItemActivatedTarget())

|| (GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_PLACEABLE)

|| GetIsObjectValid(GetItemActivatedTarget())

){

 

SendMessageToPC(GetItemActivator(), "Improper use of item!");

return;}

 

object oTarget;

object oSpawn;

location lTarget;

oPC = GetItemActivator();

 

lTarget = GetItemActivatedTargetLocation();

 

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "restallowingplacable", lTarget);

 

}

}

 

So, the problem here is that it won't work.....the next issue I am having here is that it is not spawning (probably cause I used a few lines too much or something) 

 

but then there is also another issue I am having on finding out, I also want to make it so that the player can despawn it by activating the item again.

 

so if anyone can help me with this I would REALLY appreciate it! '<img'>


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Spawn and despawning placeable.... some help please?
« Reply #1 on: April 15, 2015, 10:39:22 pm »


               I assume this is a snippet within the OnItemActivated event script?


The initial check only needs GetIsObjectValid. If the object is not valid, then it's a location, so we're good.


The rest should then work as long as restallowingplaceable is a valid resref.


To enable despawn later, use SetLocalObject on the PC to store the object created.


To despawn - at the start of the script, if that local object is valid, destroy it, DeleteLocalObject and finish.
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Spawn and despawning placeable.... some help please?
« Reply #2 on: April 17, 2015, 03:04:47 pm »


               

soooo practically would need to write another script for the despawn or the enabling of it? Sorry for the probably too noobish to describe questions but still tying to get the hang of it :S



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Spawn and despawning placeable.... some help please?
« Reply #3 on: April 17, 2015, 03:21:43 pm »


               

I smell Lilac Souls Script generator. Hehe


Nothing wrong with that - but I do find that it can impede your learning.


Your doing the right thing with regards to asking for help - its the best way to learn.


 


I recommend taking a script that works, and try to write it again in free-hand - so to speak.


Once you become fluent in the language, the skies the limit as far as what you can achieve.


 
object oTarget = GetItemActivatedTarget();
if(oTarget != OBJECT_INVALID)
{
       // We targetted something
       if(GetTag(oTarget)=="campire")
          {
               DestroyObject(oTarget,0.25);
          }
return;
}
//We targetted the ground
CreateObject(OBJECT_TYPE_PLACEABLE, "restallowingplacable", GetItemActivatedTargetLocation(),"campfire");

               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Spawn and despawning placeable.... some help please?
« Reply #4 on: April 17, 2015, 05:30:15 pm »


               


 


I smell Lilac Souls Script generator. Hehe


Nothing wrong with that - but I do find that it can impede your learning.


Your doing the right thing with regards to asking for help - its the best way to learn.


 


I recommend taking a script that works, and try to write it again in free-hand - so to speak.


Once you become fluent in the language, the skies the limit as far as what you can achieve.



 
object oTarget = GetItemActivatedTarget();
if(oTarget != OBJECT_INVALID)
{
       // We targetted something
       if(GetTag(oTarget)=="campire")
          {
               DestroyObject(oTarget,0.25);
          }
return;
}
//We targetted the ground
CreateObject(OBJECT_TYPE_PLACEABLE, "restallowingplacable", GetItemActivatedTargetLocation(),"campfire");



heheh yeah I admit i am using lilac soul for most of my scripting (well everything really), I am still in the far beginning stages of it. Though hence why I am trying to learn while I am making/scripting things. Of course I very much appreciate any help people can offer '<img'> 


 


EDIT: Okay i tried that script although somehow it just did not seem to match with the other script I have in with the OnActivateItem event (mod props).


 


I used the lilac soul thing and it did what I wanted, although it did not destroy/despwaned the item.  :S