Page 2 of 2

Re: getPosition() & setPosition()

Posted: Fri Nov 14, 2014 4:57 am
by Scotty
Jouki wrote:I've tried set position to this stone but idk what am I doing wrong

Code: Select all

function resetPuzzle()
	local x1,y1,f1 = trigger_stone_01:getPosition()
	local x2,y2,f2 = trigger_stone_02:getPosition()
	stonn1 = findEntity("stone_1")
	stonn2 = findEntity("stone_2")
	stonn1:setPosition(5,x1,y1,f1,0,0)
	stonn2:setPosition(5,x2,y2,f2,0,0)
end
variables stonn1 & 2 was made just for sure but it still doesn't work.

Message: Image
The values to pass to setPosition go: x, y, facing, elevation, level. Facing being a number 0 - 3, and level being the level_index which will always be > 0. You're using y as elevation, with a level_index that doesn't exist. Try this:

Code: Select all

function resetPuzzle()
	local x1,y1,f1 = trigger_stone_01:getPosition()
	local x2,y2,f2 = trigger_stone_02:getPosition()
	stonn1 = findEntity("stone_1")
	stonn2 = findEntity("stone_2")
	stonn1:setPosition(x1,y1-1,0,0,1)
	stonn2:setPosition(x2,y2-1,0,0,1)
end
That should return the stones 1 square north of the triggers.

Re: getPosition() & setPosition()

Posted: Fri Nov 14, 2014 11:15 am
by Jouki
Scotty wrote:
Jouki wrote:I've tried set position to this stone but idk what am I doing wrong

Code: Select all

function resetPuzzle()
	local x1,y1,f1 = trigger_stone_01:getPosition()
	local x2,y2,f2 = trigger_stone_02:getPosition()
	stonn1 = findEntity("stone_1")
	stonn2 = findEntity("stone_2")
	stonn1:setPosition(5,x1,y1,f1,0,0)
	stonn2:setPosition(5,x2,y2,f2,0,0)
end
variables stonn1 & 2 was made just for sure but it still doesn't work.

Message: Image
The values to pass to setPosition go: x, y, facing, elevation, level. Facing being a number 0 - 3, and level being the level_index which will always be > 0. You're using y as elevation, with a level_index that doesn't exist. Try this:

Code: Select all

function resetPuzzle()
	local x1,y1,f1 = trigger_stone_01:getPosition()
	local x2,y2,f2 = trigger_stone_02:getPosition()
	stonn1 = findEntity("stone_1")
	stonn2 = findEntity("stone_2")
	stonn1:setPosition(x1,y1-1,0,0,1)
	stonn2:setPosition(x2,y2-1,0,0,1)
end
That should return the stones 1 square north of the triggers.
thanks, works perfectly!

Re: getPosition() & setPosition()

Posted: Fri Nov 14, 2014 11:26 am
by Jouki
I've got interesting effect, I had a stone on coords for example 10,13 and I moved him onto 10,12 after reseting the stones it appear on right position but at the [10,12] is still invisible obstacle of the stone. actaully it "copied" so now I have obstacle at 10,13 (the stone, visible) and 10,12 where it was before reseting (setting the position) and as I said it's invisible, not a proper clone of the object "stone"

EDIT: maybe I should try destroy them and spawn them again on that position

Re: getPosition() & setPosition()

Posted: Wed Dec 31, 2014 10:06 pm
by Mentok
Jouki wrote:I've got interesting effect, I had a stone on coords for example 10,13 and I moved him onto 10,12 after reseting the stones it appear on right position but at the [10,12] is still invisible obstacle of the stone. actaully it "copied" so now I have obstacle at 10,13 (the stone, visible) and 10,12 where it was before reseting (setting the position) and as I said it's invisible, not a proper clone of the object "stone"

EDIT: maybe I should try destroy them and spawn them again on that position
I ran into the same problem. It seems like the .dynamicobstacle component gets left behind somehow. I just went the destroy and spawn route and that seems to be working fine so far.

function puzzreset()

pushable_block_1:destroy()
pushable_block_2:destroy()
spawn("pushable_block", 4, 19, 23, 1, -1, "pushable_block_1")
spawn("pushable_block", 4, 20, 23, 1, -1, "pushable_block_2")

end