samplespawner.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import rxactor
  2. import sys
  3. import clr
  4. import random
  5. import math
  6. asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
  7. Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
  8. # Sample tree
  9. class Tree(rxactor.Actor):
  10. def GetScriptClassName():
  11. return "samplespawner.Tree"
  12. def EventCreated(self):
  13. super(self.__class__,self).EventCreated()
  14. self.GrowCount = 1
  15. self.SetMesh("birch2")
  16. self.SetMaterial(0,"oksa5")
  17. self.SetMaterial(1,"lehtipuu_kuori")
  18. self.SetTimer(0.05,True)
  19. def EventTimer(self):
  20. self.GrowCount += 1
  21. if(self.GrowCount > 70):
  22. self.SetTimer(0,False)
  23. else:
  24. self.Scale = Vector3(0.0175*self.GrowCount,0.03125*self.GrowCount,0.0375*self.GrowCount)
  25. # Forest spawner
  26. class Spawner(rxactor.Actor):
  27. def GetScriptClassName():
  28. return "samplespawner.Spawner"
  29. def EventTouch(self,vAvatar):
  30. for i in range(0, 3):
  31. tempang = random.random()*2*math.pi
  32. x = math.sin(tempang) * random.random() * 15
  33. y = math.cos(tempang) * random.random() * 15
  34. spawnloc = self.llGetPos() + Vector3(x,y,0)
  35. self.SpawnActor(spawnloc,0,False,"samplespawner.Tree")