Yes. Items have a subtileOffset that can be changed; offsetting their default position.Curunir wrote:...is there a way to place items in an alcove and NOT have them appear inside each other?
eg.
GameObject:setSubtileOffset(x, y)
Yes. Items have a subtileOffset that can be changed; offsetting their default position.Curunir wrote:...is there a way to place items in an alcove and NOT have them appear inside each other?
I was fully convinced I put openSesame outside of the upper function! Thanks for pointing it out!minmay wrote:Your definition of the openSesame function is inside the coldDoor function - and after the attempt to call it, so of course it's nil when you attempt to call it.
So, I place whatever I want on an alcove from inside the editor, then use the alcove item id-s to offset them that way in any script entity, outside of any function?Isaac wrote:Yes. Items have a subtileOffset that can be changed; offsetting their default position.
eg.
GameObject:setSubtileOffset(x, y)
Code: Select all
defineObject{
name = "tomeskill_learner",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/tome.fbx",
material = "book4",
},
{
class = "Item",
uiName = "The Incredible Mystery Of Life",
description = "A thick tome made by an old crook who teach us to better know ourself and increase our learning experience.",
gfxAtlas = "mod_assets/textures/oliveitem.tga",
gfxIndex = 13,
weight = 1.0,
gameEffect = "Gain Learner Skill +1",
traits = { "tome" },
},
{
class = "UsableItem",
sound = "level_up",
onUseItem = function(self, champion)
hudPrint(champion:getName().." gained Learner +1.")
champion:trainSkill("perfection", 1)
return true
end,
},
},
}
Yes.Curunir wrote:So, I place whatever I want on an alcove from inside the editor, then use the alcove item id-s to offset them that way in any script entity, outside of any function?
Code: Select all
for _,item in dungeon_alcove_1.surface:contents() do
item.go:setSubtileOffset(1.5,-.2)
break
end
Code: Select all
function jostle(container, seed) --Intended to shift the contents of chests.
if container and type(container) ~= 'table' then container = findEntity(container)
end
if seed and type(seed) == "number" then
math.randomseed(seed)
end
if not container.name:match('alcove') then
for _,items in container.surface:contents() do
items.go:setSubtileOffset((math.random()-.5)/2,(math.random()-.5)/2)
end
else local offset = 1.3
local dX, dY = getForward(container.facing)
if ((container.facing+1)%2) ~= 1 then
offset = offset * -1
end
if dX ~= 0 then dX = dX * offset end
if dY ~= 0 then dY = dY * offset end
for _,items in container.surface:contents() do
items.go:setSubtileOffset(dX+(math.random()-.5)/2,dY+(math.random()-.5)/2)
end
end
end
function string2bytes(text)
local result = ""
for x = 1, #text do
result = result..string.byte(text, x)
end
return tonumber(result)
end
for x = 1, Dungeon.getMaxLevels() do
for entity in self.go.map:allEntities(x) do
if entity.surface and entity.surface:count() > 0
then
jostle(entity.id)
end
end
end
minmay wrote:champion:trainSkill("perfection",1,false)
Code: Select all
for _,v in pairs(someTable) do