Jump to content

[Solved] Help me!! Assert failed.


Yue
 Share

Recommended Posts

When I collide with a stage element with collision trigger I get this error sporadically and the game closes.

Any suggestions?

 

function Script:Collision(entity, position, normal, speed)

	if entity:GetKeyValue("name") == "Yue" then 
		
		if self.element == 0 then 
			self.entity:Hide()
			self.Hud.script:ResetOxygen()
			if self.Hud.script.gOxygen == 1 then 
				self.sOxygen:Play()
			end
		elseif self.element == 1 then 
			if self.Hud.script.gLife < 128 then 
				self.entity:Hide()
				self.Hud.script:ResetLife()
				if self.Hud.script.gLife < 120 then 
					self.sRelief:Play()
				end
			end
		elseif self.element == 2 then 
			
				-- Here Problem.
		
				self.entity:Release()
				--if self.Inv.script.Inv:GetEpo() < 5   then 
				
			
		
				--self.pickUp:Play()
				self.Inv.script:AddEpo()
			
				
			
			--end
		end
		
	end 
	
end

image.thumb.png.a2041e3edc6782f5d45eedeccbdda066.png

 

 

Link to comment
Share on other sites

How can I do so that the code is not replicated inside the collision scrip. What happens is that I have to increment an inventory variable each time it takes a new element.  Then the variable must rise from 0 ( it doesn't have the item ) to 1 when it takes that item. But what happens is that it goes to number 2.

 

 

Link to comment
Share on other sites

Yes, what happens is that if I hide it, it takes a while to disappear and the variable instead of increasing a value to 1 increases 2 or 3 values.

variableItem = 0

Collision variableItem = variableItem + 1

But the result is not 1, but 2 or 3.

I'm thinking of doing it outside the collider function with a fla

 

 

Link to comment
Share on other sites

Ok, solved Here. Thanks YOu.

 

-##################################################
--# Proyecto 	: Astrocuco
--# Scripter  	: Yue Rexie.
--# Sitio Web	: https://www.iris3dgames.xyz
--# Fichero		: Element.lua
--##################################################
--# Notas		: Fichero enganchado a la entidad
--#				  en contexto.
--##################################################

import("Scripts/Game/Sounds/CSound.lua")

Script.element = 0 --choice "Element" "Oxygen, Health, Stamine"
Script.state   = 1 --choice "State" "Damage, Recovery, Inven"
-- Pendiente.
function Script:Start()
	
	self.Hud = World:GetCurrent():FindEntity("Hud")

	if self.element ==  0 then 
		self.sOxygen = CSound:Create("RecoveryOxygen")
		self.sOxygen:SetLoopMode(false)
		self.sOxygen:SetVolume(0.15)
	end 

	if self.element == 1 then 
		self.sRelief = CSound:Create("Relief")
		self.sRelief:SetLoopMode(false)
		self.sRelief:SetVolume(0.15)
	end 


	if self.element == 2 then 
		self.pickUp = CSound:Create("Cremallera")
		self.pickUp:SetLoopMode(false)
		self.pickUp:SetVolume(0.5)
		self.Inv  = World:GetCurrent():FindEntity("Inventario")
	end

	
	self.collisionEpo = false
	

end

function Script:Collision(entity, position, normal, speed)


	if entity:GetKeyValue("name") == "Yue" then 
		
	
		if self.element == 0 then 
			self.entity:Hide()
			self.Hud.script:ResetOxygen()
			if self.Hud.script.gOxygen == 1 then 
				self.sOxygen:Play()
			end
		elseif self.element == 1 then 
			if self.Hud.script.gLife < 128 then 
				self.entity:Hide()
				self.Hud.script:ResetLife()
				if self.Hud.script.gLife < 120 then 
					self.sRelief:Play()
				end
			end
		elseif self.element == 2 then 
			
				if self.Inv.script.Inv:GetEpo() < 5   then 
				self.entity:Hide()
				self.pickUp:Play()
				self.collisionEpo = true
			
				end
		end
		
	end
	
end


function Script:UpdateWorld()
	-- Here variable change + 1.
	if self.collisionEpo == true then 
		self.collisionEpo = false 
		self.Inv.script:AddEpo()
	end 
	if self.entity:GetKeyValue("name") == "KitHealth" then 
		self.entity:Turn(0,0,2)
	elseif self.entity:GetKeyValue("name") == "Epo" then 
			self.entity:Turn(1,1,1)
			
	end
end

 

  • Like 1

 

 

Link to comment
Share on other sites

  • Yue changed the title to [Solved] Help me!! Assert failed.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...