Guest User

Untitled

a guest
May 18th, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. -- manifest.json
  2.  
  3. {
  4.  
  5.  
  6. "info": {
  7. "name": "Command Item Spawner",
  8. "version": 1
  9. },
  10.  
  11. "functions": {
  12. "create_item_iconic": {
  13. "controller": "file(call_handlers/item_spawn_handler.lua)",
  14. "endpoint": "server"
  15. },
  16. "create_item": {
  17. "controller": "file(call_handlers/item_spawn_handler.lua)",
  18. "endpoint": "server"
  19. },
  20. "create_item_other": {
  21. "controller": "file(call_handlers/item_spawn_handler.lua)",
  22. "endpoint": "server"
  23. },
  24. "select_location_item_iconic": {
  25. "controller": "file(call_handlers/item_select_handler.lua)",
  26. "endpoint" : "client"
  27. }
  28. }
  29. }
  30.  
  31. -- item_select_handler.lua
  32. local Point3 = _radiant.csg.Point3
  33. local log = radiant.log.create_logger('item_spawn_call_logger_client')
  34.  
  35. local ItemSelectHandler = class()
  36.  
  37. function ItemSelectHandler:select_location_item_iconic(session, response, item)
  38.  
  39. local entity = radiant.entities.create_entity(item)
  40. stonehearth.selection:select_location():set_cursor_entity(entity):done(
  41.  
  42. function(selector, location, rotation)
  43. radiant.entities.destroy_entity(entity)
  44. _radiant.call('itemspawn:create_item_iconic',item,location):always(function(result)
  45. selector:destroy()
  46. end)
  47. end):fail(
  48. function(selector)
  49. selector:destroy()
  50. end):go()
  51.  
  52. return true
  53. end
  54.  
  55. return ItemSelectHandler
  56. -- item_spawn_handler.lua
  57. local Point3 = _radiant.csg.Point3
  58. local log = radiant.log.create_logger('item_spawn_call_logger')
  59.  
  60.  
  61.  
  62. local ItemSpawnHandler = class()
  63.  
  64. function ItemSpawnHandler:create_item_iconic(session, response, item, loc)
  65.  
  66.  
  67. log:info('were here. yipeeyododleu')
  68. local entity = radiant.entities.create_entity(item)
  69. radiant.terrain.place_entity(entity, Point3(loc.x,loc.y,loc.z), {force_iconic = true})
  70.  
  71.  
  72.  
  73.  
  74.  
  75. return true
  76. end
  77.  
  78. function ItemSpawnHandler:create_item(session, response, item, x, y, z)
  79. local entity = radiant.entities.create_entity(item)
  80. radiant.terrain.place_entity(entity, Point3(tonumber(x), tonumber(y), tonumber(z)), { })
  81. return true
  82. end
  83.  
  84. function ItemSpawnHandler:create_item_other(session, response, item, x, y, z, iconic, owner)
  85. local entity = radiant.entities.create_entity(item)
  86.  
  87. if owner == 'player_1' then
  88. entity:add_component('unit_info'):set_player_id(owner)
  89. end
  90.  
  91. radiant.terrain.place_entity(entity, Point3(tonumber(x), tonumber(y), tonumber(z)), { force_iconic = iconic })
  92. end
  93.  
  94. return ItemSpawnHandler
Advertisement
Add Comment
Please, Sign In to add comment