Advertisement
maxkhl

Outpost Omega - Lua API Examples

Apr 24th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. --[=====[
  2. Outpost Omega - Lua API Examples
  3. --]=====]
  4.  
  5. -- 1: Hello World!
  6. print("Example 1: Hello World")
  7. print("Hello World!")
  8.  
  9. -- 2: Get a GameObject and do stuff with it
  10. print("Example 2: Get a GameObject and do stuff")
  11. firstgameobject = GetFirstGO("")
  12. print(firstgameobject.ID)
  13. print(firstgameobject.Position)
  14. print(firstgameobject.Static)
  15. print(firstgameobject.IsPhysical)
  16.  
  17. firstgameobject:SetPosition(Vector3(10, 10, 10))
  18.  
  19. if(firstgameobject.IsPhysical) then
  20.     firstgameobject:PhysicDisable()
  21. end
  22.  
  23. -- 3: Get all GameObjects and print details about them
  24. print("Example 3: All loaded GameObjects")
  25. gameobjects = GetGO("")
  26. for k, v in pairs(gameobjects) do
  27.   print(k .. " - " .. v.Position:ToString())
  28. end
  29.  
  30. -- 4: Create a new GameObject
  31. print("Example 4: Create a new GameObject")
  32. builder = NewBuilder() 
  33. builder.ClassName = "NiceObject"
  34. builder:SetParent("OutpostOmega.Game.gObject.structure.machinery.machinery")
  35.  
  36. builder:AddAttribute("OutpostOmega.Game.gObject.attributes.Definition",  {"Nice Object", "What a nice object. Holy sheeet"})
  37. builder:AddAttribute("OutpostOmega.Game.gObject.attributes.Construction",  { getType("OutpostOmega.Game.gObject.structure.Frame"), getType("OutpostOmega.Game.gObject.item.tool"), "Content\\\Model\\\Structure\\Machinery\\\Doors\\\Airlock.dae"})
  38.  
  39. builder:Hook("Constructor",
  40. function(myObject) -- the constructor point will pass the new created instance
  41.     myObject.Model = "Content\\\Model\\\Structure\\Machinery\\\Dooars\\\Airlock.dae"
  42. end)
  43.  
  44. builder:Hook("KeyPress",
  45. function(myObject, Key, IsRepeat)
  46.     if(IsKey(Key, "E") and IsRepeat) then  
  47.         myObject:Dispose()
  48.     end
  49. end)
  50.  
  51. newType = builder:Compile()
  52.  
  53. print(newType)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement