Page 69 of 396

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 6:32 am
by st1nger
Eleven Warrior wrote:Hi all. I have forgot how to do this (code below) When floor_trigger_3 is down something happens. If floor_trigger_3 is up something happens. The error I am getting is with the (isDown) bit. Please help I know it's easy imam sure thxs :)

Code: Select all

function checkLevers()

    if floor_trigger_3:isDown() then
hudPrint("hello")
	else if floor_trigger_3:isUp() then
hudPrint("bye")
 
end
end
end

hi :)

I have corrected the code
this works:

Code: Select all

function checkLevers()
	if floor_trigger_3.floortrigger:isActivated() then
		hudPrint("hello")
	else floor_trigger_3.floortrigger:isDeactivated()
		hudPrint("bye")
    end
end

floortrigger has only 2 stages, you dont need to check for isDeactivated() when you check for isActivated() one line above.

this works also fine:

Code: Select all

function checkLevers()
	if floor_trigger_3.floortrigger:isActivated() then
		hudPrint("hello")
	else
		hudPrint("bye")
    end
end

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 7:12 pm
by AndakRainor
hi! When I use

Code: Select all

o:setPosition(o.x, o.y, o.facing, ground, o.level)
on a GameObject o with an obstacle component, the previous position of the object is still considered blocked by the game. Why ? What should I do to avoid this strange behavior ?

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 7:28 pm
by Isaac
AndakRainor wrote:hi! When I use

Code: Select all

o:setPosition(o.x, o.y, o.facing, ground, o.level)
on a GameObject o with an obstacle component, the previous position of the object is still considered blocked by the game. Why ? What should I do to avoid this strange behavior ?
Any object? That did not happen when I tried it in the editor with an altar.
Nor with a barrel crate blockage.

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 7:31 pm
by minmay
Was the object a pushable block by any chance?

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 7:32 pm
by Isaac
It does happen with pushable_blocks and no floor. [With or without.]

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 7:57 pm
by AndakRainor
Yes it also has a PushableBlock component and DynamicObstacle component... Is it hopeless ?

Code: Select all

defineObject{
	name = "ice_cube",
	baseObject = "base_obstacle",
	components = {
		{
			class = "Model",
			model = "assets/models/env/pushable_block_01.fbx",
         material = "ice_cube",
			offset = vec(0, 0.05, 0),
		},
		{
			class = "Light",
			offset = vec(0, 1.75, 0),
			range = 6,
			color = vec(0.2, 0.5, 1),
			brightness = 20,
			castShadow = false,
			fillLight = true,
		},
		{
			class = "Particle",
			particleSystem = "force_field",
		},
		{
			class = "Sound",
			sound = "force_field_ambient",
		},
		{
			class = "ProjectileCollider",
		},
		{
			class = "Obstacle",
			hitSound = "terracotta_jar_hit",
			hitEffect = "hit_terracotta_jar",
		},
		{
			class = "Health",
			health = 50,
         immunities = { "cold" },
		},
		{
			class = "DynamicObstacle",
		},
      userData,
      {
         class = "Timer",
         timerInterval = 0.001,
         triggerOnStart = true,
         onActivate = function(self)
           self.go.data:set("vz", spells_functions.script.checkUnder(self.go.id, self.go.data:get("vz") or 0, Time.deltaTime()))
         end,
      },
		{
			class = "PushableBlock",
		},
		{
			class = "Clickable",
			name = "clickNorth",
			offset = vec(0, 1.15, 1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				hudPrint("push north!")
            --self.go.gravity:setFallingSpeed(1)
				if party.facing == (self.go.facing+2) % 4 then
              self.go.pushableblock:activate()
              if ice_push_source then ice_push_source:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation, ice_push_source).controller:activate()
              local dx,dy = getForward(party.facing)
              if ice_push_target then ice_push_target:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x+dx, self.go.y+dy, self.go.facing, self.go.elevation, ice_push_target).controller:activate()
	           self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickEast",
			offset = vec(1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				hudPrint("push east!")
				if party.facing == (self.go.facing+3) % 4 then
              self.go.pushableblock:activate()
              if ice_push_source then ice_push_source:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation, ice_push_source).controller:activate()
              local dx,dy = getForward(party.facing)
              if ice_push_target then ice_push_target:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x+dx, self.go.y+dy, self.go.facing, self.go.elevation, ice_push_target).controller:activate()
              self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickSouth",
			offset = vec(0, 1.15, -1.2),
			size = vec(1.2, 1.2, 0.1),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				hudPrint("push south!")
				if party.facing == self.go.facing then
              self.go.pushableblock:activate()
              if ice_push_source then ice_push_source:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation, ice_push_source).controller:activate()
              local dx,dy = getForward(party.facing)
              if ice_push_target then ice_push_target:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x+dx, self.go.y+dy, self.go.facing, self.go.elevation, ice_push_target).controller:activate()
              self.go.pushableblock:push(party.facing)
				end
			end,
		},
		{
			class = "Clickable",
			name = "clickWest",
			offset = vec(-1.2, 1.15, 0),
			size = vec(0.1, 1.2, 1.2),
			maxDistance = 1,
			--debugDraw = true,
			onClick = function(self)
				hudPrint("push west!")
            if party.facing == (self.go.facing+1) % 4 then
              self.go.pushableblock:activate()
              if ice_push_source then ice_push_source:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation, ice_push_source).controller:activate()
              local dx,dy = getForward(party.facing)
              if ice_push_target then ice_push_target:destroy() end
              spawn("ice_pushable_block_floor", self.go.level, self.go.x+dx, self.go.y+dy, self.go.facing, self.go.elevation, ice_push_target).controller:activate()
              self.go.pushableblock:push(party.facing)
				end
			end,
		},
	},
	placement = "floor",
	editorIcon = 272,
	tags = { "obstacle" },
}

defineObject{
	name = "ice_pushable_block_floor",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "PushableBlockFloor",
			name = "controller",
		},
	},
	replacesFloor = false,
}

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 8:33 pm
by Isaac
Just remove the dynamicobstacle compontent, move the object, then create the dynamicobstacle component again.
(Disabling it is not sufficient.)

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 8:37 pm
by AndakRainor
I just found out that DynamicObstacle is the culprit ! This component is needed to spawn the object (don't know why but without it an error is raised), but it can be disabled from the very start (enabled = false); it solves the problem and doesn't affect the other behaviors of the block !

PS: now I need to make sure a platform follows the top of this block so it can be walked over and it will finally be finished ! So much pain !

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 8:47 pm
by AndakRainor
Isaac wrote:Just remove the dynamicobstacle compontent, move the object, then create the dynamicobstacle component again.
(Disabling it is not sufficient.)
Well, after testing it it seems the previous position is correctly released, and as an obstacle and a pushable block it still correctly moves. What would be missing without the destruction and creation you suggest ?

Re: Ask a simple question, get a simple answer

Posted: Thu May 28, 2015 9:14 pm
by Isaac
AndakRainor wrote:
Isaac wrote:Just remove the dynamicobstacle compontent, move the object, then create the dynamicobstacle component again.
(Disabling it is not sufficient.)
Well, after testing it it seems the previous position is correctly released, and as an obstacle and a pushable block it still correctly moves. What would be missing without the destruction and creation you suggest ?
If you do not remove the dynamicobstacle component, it blocks the original tile, but releases as soon as the block is pushed. If you disable it instead of removing it, the tile is freed ~until you enable it again. If you remove it, and create it again, it just works as one would expect (aside from the unexpected need for this kludge). I don't think that anything is or would be missing, but I'm not exactly sure what you mean.