I've been away from starbound for about 2 months and things have changed a lot since that time. I'm trying to work on my mod and I need to figure out a way to access active item parameters via lua. I know I can access them by adding lua to the item but I don't know how to access them from tech lua. I'm still digging asset files to find some answers. If anyone knows how to do it, I would like to borrow some of his/her knowledge.
I hope you're still looking for help, because i went on an adventure to figure this out. Code i put into the bounce.lua tech script: (log and serialize i added as well but they just help with the output) Code: function handCheck( id, hand) log("Trying to see whats in the "..hand.." hand:") --getting the name of a held item local sItemName = world.entityHandItem( id, hand) if sItemName then --getting item type local sItemType = world.itemType(sItemName) log("Ah, it is clearly "..sItemName..", a "..sItemType) --getting descriptor local tItemDesc = world.entityHandItemDescriptor( id, hand) log("Some details about the actual item: "..serialize(tItemDesc)) --getting item config details local tConfig = root.itemConfig(sItemName) log("Here's what the codex says about the item in general: "..serialize(tConfig)) else log("It was nothing!") end --note: could possibly use world.sendEntityMessage( id, "functionName", params) to dig deeper and ultimately have access to entity.getItemSlot on the player (which in turn might give access to the entire hotbar) end function getAllHeldItemParameters() log("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") log("Let's get this started:") --here's how to get the players id local playerId = entity.id() handCheck(playerId, "primary") handCheck(playerId, "alt") end The output from the stdout.txt Code: Info: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Info: Let's get this started: Info: Trying to see whats in the primary hand: Info: Ah, it is clearly flashlight, a flashlight Info: Some details about the actual item: { count = 1, name = "flashlight", parameters = {}, } Info: Here's what the codex says about the item in general: { directory = "/items/tools/", config = { itemName = "flashlight", beamAmbience = 0.4, description = "A handy flashlight!", lightPosition = { 4, 0, }, tooltipKind = "tool", price = 100, inventoryIcon = "flashlighticon.png", rarity = "Uncommon", handPosition = { -2, 0, }, image = "flashlight.png", maxStack = 1, shortdescription = "Flashlight", largeImage = "flashlightlarge.png", lightColor = { 220, 220, 220, }, beamLevel = 5, }, parameters = {}, } Info: Trying to see whats in the alt hand: Info: Ah, it is clearly woodenwateringcan, a activeitem Info: Some details about the actual item: { count = 1, name = "woodenwateringcan", parameters = {}, } Info: Here's what the codex says about the item in general: { directory = "/items/active/unsorted/wateringcan/", config = { scripts = { "wateringcan.lua", }, animationParts = { wateringcan = "woodenwateringcan.png", }, description = "Gently and efficiently water your crops.", tooltipKind = "base", projectileInaccuracy = 0.3, animation = "wateringcan.animation", rarity = "common", shortdescription = "Wooden Watering Can", projectileParameters = { timeToLive = 5, color = { 10, 255, 10, }, power = 0, speed = 8, }, projectileRate = 0.25, waterTime = 1.0, itemName = "woodenwateringcan", maxStack = 1, waterAngle = 10, projectileType = "watersprinkledroplet", twoHanded = false, animationCustom = {}, cooldownTime = 1.0, inventoryIcon = "woodenwateringcan.png", }, parameters = {}, } Info: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Info: Let's get this started: Info: Trying to see whats in the primary hand: Info: Ah, it is clearly platinumdrill, a miningtool Info: Some details about the actual item: { count = 1, name = "platinumdrill", parameters = { durabilityHit = 160.0, }, } Info: Here's what the codex says about the item in general: { directory = "/items/tools/miningtools/", config = { breakSound = "/sfx/tools/pickaxe_break.ogg", durabilityPerUse = 1, description = "Drills fast but breaks quickly. A temporary alternative to the matter manipulator.", swingFinish = 0, tooltipKind = "tool", handPosition = { -8, 1, }, altBlockRadius = 1, price = 300, tileDamageBlunted = 0.2, rarity = "Uncommon", inventoryIcon = "platinumdrillicon.png", itemName = "platinumdrill", maxStack = 1, harvestLevel = 99, blockRadius = 2, fireTime = 0.1, shortdescription = "Platinum Drill", frames = 5, strikeSounds = { "/sfx/tools/drill_hit.ogg", }, animationCycle = 0.1, image = "platinumdrill.png:{frame}", durability = 1000, largeImage = "platinumdrillbig.png", idleSound = "/sfx/tools/chainsaw_idle.ogg", twoHanded = true, pointable = true, tileDamage = 3, swingStart = 0, }, parameters = {}, } Info: Trying to see whats in the alt hand: Info: It was nothing!
Pretty sure the watering can script takes some values from the .activeitem file. The Watering can can possibly be found somewhere around activeitem/unsorted/...
Well, actually, wateringcan.lua is the script that is directly attached to the wateringcan.activeitem so it is kind of natural that it can use all the parameters. I'm trying to find out how to access from a lua file which is not directly attached to the item.
I hope you're still looking for help, because i went on an adventure to figure this out. Code i put into the bounce.lua tech script: (log and serialize i added as well but they just help with the output) Code: function handCheck( id, hand) log("Trying to see whats in the "..hand.." hand:") --getting the name of a held item local sItemName = world.entityHandItem( id, hand) if sItemName then --getting item type local sItemType = world.itemType(sItemName) log("Ah, it is clearly "..sItemName..", a "..sItemType) --getting descriptor local tItemDesc = world.entityHandItemDescriptor( id, hand) log("Some details about the actual item: "..serialize(tItemDesc)) --getting item config details local tConfig = root.itemConfig(sItemName) log("Here's what the codex says about the item in general: "..serialize(tConfig)) else log("It was nothing!") end --note: could possibly use world.sendEntityMessage( id, "functionName", params) to dig deeper and ultimately have access to entity.getItemSlot on the player (which in turn might give access to the entire hotbar) end function getAllHeldItemParameters() log("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") log("Let's get this started:") --here's how to get the players id local playerId = entity.id() handCheck(playerId, "primary") handCheck(playerId, "alt") end The output from the stdout.txt Code: Info: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Info: Let's get this started: Info: Trying to see whats in the primary hand: Info: Ah, it is clearly flashlight, a flashlight Info: Some details about the actual item: { count = 1, name = "flashlight", parameters = {}, } Info: Here's what the codex says about the item in general: { directory = "/items/tools/", config = { itemName = "flashlight", beamAmbience = 0.4, description = "A handy flashlight!", lightPosition = { 4, 0, }, tooltipKind = "tool", price = 100, inventoryIcon = "flashlighticon.png", rarity = "Uncommon", handPosition = { -2, 0, }, image = "flashlight.png", maxStack = 1, shortdescription = "Flashlight", largeImage = "flashlightlarge.png", lightColor = { 220, 220, 220, }, beamLevel = 5, }, parameters = {}, } Info: Trying to see whats in the alt hand: Info: Ah, it is clearly woodenwateringcan, a activeitem Info: Some details about the actual item: { count = 1, name = "woodenwateringcan", parameters = {}, } Info: Here's what the codex says about the item in general: { directory = "/items/active/unsorted/wateringcan/", config = { scripts = { "wateringcan.lua", }, animationParts = { wateringcan = "woodenwateringcan.png", }, description = "Gently and efficiently water your crops.", tooltipKind = "base", projectileInaccuracy = 0.3, animation = "wateringcan.animation", rarity = "common", shortdescription = "Wooden Watering Can", projectileParameters = { timeToLive = 5, color = { 10, 255, 10, }, power = 0, speed = 8, }, projectileRate = 0.25, waterTime = 1.0, itemName = "woodenwateringcan", maxStack = 1, waterAngle = 10, projectileType = "watersprinkledroplet", twoHanded = false, animationCustom = {}, cooldownTime = 1.0, inventoryIcon = "woodenwateringcan.png", }, parameters = {}, } Info: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Info: Let's get this started: Info: Trying to see whats in the primary hand: Info: Ah, it is clearly platinumdrill, a miningtool Info: Some details about the actual item: { count = 1, name = "platinumdrill", parameters = { durabilityHit = 160.0, }, } Info: Here's what the codex says about the item in general: { directory = "/items/tools/miningtools/", config = { breakSound = "/sfx/tools/pickaxe_break.ogg", durabilityPerUse = 1, description = "Drills fast but breaks quickly. A temporary alternative to the matter manipulator.", swingFinish = 0, tooltipKind = "tool", handPosition = { -8, 1, }, altBlockRadius = 1, price = 300, tileDamageBlunted = 0.2, rarity = "Uncommon", inventoryIcon = "platinumdrillicon.png", itemName = "platinumdrill", maxStack = 1, harvestLevel = 99, blockRadius = 2, fireTime = 0.1, shortdescription = "Platinum Drill", frames = 5, strikeSounds = { "/sfx/tools/drill_hit.ogg", }, animationCycle = 0.1, image = "platinumdrill.png:{frame}", durability = 1000, largeImage = "platinumdrillbig.png", idleSound = "/sfx/tools/chainsaw_idle.ogg", twoHanded = true, pointable = true, tileDamage = 3, swingStart = 0, }, parameters = {}, } Info: Trying to see whats in the alt hand: Info: It was nothing!