Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- manifest.json
- {
- "info": {
- "name": "Command Item Spawner",
- "version": 1
- },
- "functions": {
- "create_item_iconic": {
- "controller": "file(call_handlers/item_spawn_handler.lua)",
- "endpoint": "server"
- },
- "create_item": {
- "controller": "file(call_handlers/item_spawn_handler.lua)",
- "endpoint": "server"
- },
- "create_item_other": {
- "controller": "file(call_handlers/item_spawn_handler.lua)",
- "endpoint": "server"
- },
- "select_location_item_iconic": {
- "controller": "file(call_handlers/item_select_handler.lua)",
- "endpoint" : "client"
- }
- }
- }
- -- item_select_handler.lua
- local Point3 = _radiant.csg.Point3
- local log = radiant.log.create_logger('item_spawn_call_logger_client')
- local ItemSelectHandler = class()
- function ItemSelectHandler:select_location_item_iconic(session, response, item)
- local entity = radiant.entities.create_entity(item)
- stonehearth.selection:select_location():set_cursor_entity(entity):done(
- function(selector, location, rotation)
- radiant.entities.destroy_entity(entity)
- _radiant.call('itemspawn:create_item_iconic',item,location):always(function(result)
- selector:destroy()
- end)
- end):fail(
- function(selector)
- selector:destroy()
- end):go()
- return true
- end
- return ItemSelectHandler
- -- item_spawn_handler.lua
- local Point3 = _radiant.csg.Point3
- local log = radiant.log.create_logger('item_spawn_call_logger')
- local ItemSpawnHandler = class()
- function ItemSpawnHandler:create_item_iconic(session, response, item, loc)
- log:info('were here. yipeeyododleu')
- local entity = radiant.entities.create_entity(item)
- radiant.terrain.place_entity(entity, Point3(loc.x,loc.y,loc.z), {force_iconic = true})
- return true
- end
- function ItemSpawnHandler:create_item(session, response, item, x, y, z)
- local entity = radiant.entities.create_entity(item)
- radiant.terrain.place_entity(entity, Point3(tonumber(x), tonumber(y), tonumber(z)), { })
- return true
- end
- function ItemSpawnHandler:create_item_other(session, response, item, x, y, z, iconic, owner)
- local entity = radiant.entities.create_entity(item)
- if owner == 'player_1' then
- entity:add_component('unit_info'):set_player_id(owner)
- end
- radiant.terrain.place_entity(entity, Point3(tonumber(x), tonumber(y), tonumber(z)), { force_iconic = iconic })
- end
- return ItemSpawnHandler
Advertisement
Add Comment
Please, Sign In to add comment