Jump to content

TEPA6ANT

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by TEPA6ANT

  1. How to get all objects on map
    Everything. And hiddens, and triggers.

    The thing is that I need to game received all triggers (secret rooms) when map start. And then calculate which areas were the player. To know, in any trigger (secret room) was player, I will be able do. I just need to get it, to get the maximum amount.

    I tried using a GetEntityNeighbors(), but he can't see them.

  2. Problem is solved.
    Delete:

    Script.objects={}

    Add: 

    self.objects={}

    in Script:Start()

    Now the game does not crash.

    But. I want to know.
    Are there any other options to find out that the object is a light, except what I wrote (terribly) in the code?

    if entity:GetKeyValue("name") ~= ("Point Light 2" or "Spot Light 2") then
    
  3. My game crashes after changing map. I found the problem, but I don't know how to solve it. 

    I made special zones that hide all objects in it if there is no special object in the zone (e.g. player). And show again if there is a special object in the zone.

    room.lua
     

    import "Scripts/Functions/ROOM_AABB.lua"
    
    Script.uniq=false --bool "No typical"
    Script.Special="" --string "SPECIAL commands"
    
    --Disable,Pause,Enable
    Script.state="Disable"
    
    Script.hiden = false 
    
    Script.objects={}
    
    function Script:UpdateRoom()
    	local moi_raion, spec = OBJ_inroom(self.entity,scriptOnly)
    	local index, entity
    	for index,entity in pairs(moi_raion) do
    		if entity:GetKeyValue("Camera")~="69" then
    			if spec then
    				local jndex,entity_obj 
    				for jndex,entity_obj in pairs(self.objects) do
    					entity_obj:SetKeyValue("World_Status","")
    					entity_obj:Show()
    				end
    				self.objects={}
    			else
    				entity:SetKeyValue("World_Status","DE")
    				entity:Hide()
    				table.insert(self.objects,entity)
    			end
    		end
    	end
    end
    
    function Script:Start()
    	self.entity:SetKeyValue("Room",self.Special)
    end
    
    function Script:UpdateWorld()
    
    end
    
    function Script:UpdatePhysics()
    	self:UpdateRoom()
    end


    ROOM_AABB.lua
     

    RoomInAABBDoCallbackTable = nil
    GetEntityNeighborsScriptedOnly=false
    Special_OBJ=false
    
    function GetSosedR(entity,extra)
    	--System:Print("See "..entity:GetKeyValue("Special"))
    	if entity:GetKeyValue("name") ~= ("Point Light 2" or "Spot Light 2") then
    		if entity:GetKeyValue("Special")~= ("" or nil) then
    			Special_OBJ=true
    		end
    		table.insert(RoomInAABBDoCallbackTable,entity)
    	end
    end
    
    
    function OBJ_inroom(entity,scriptOnly)
    	Special_OBJ=false
    	local result_table
    	local special
    	local position = entity:GetPosition(true)
    	local localaabb = entity:GetAABB(Entity.LocalAABB)
    	local aabb = entity:GetAABB(Entity.RecursiveAABB)
    	local temp = GetEntityNeighborsScriptedOnly
    	GetEntityNeighborsScriptedOnly=scriptOnly
    	aabb:Update()
    	local table = RoomInAABBDoCallbackTable 
    	RoomInAABBDoCallbackTable = {}
    	if entity.world then
    		entity.world:ForEachEntityInAABBDo(aabb,"GetSosedR",entity)	
    		result_table = RoomInAABBDoCallbackTable
    		special = Special_OBJ
    		RoomInAABBDoCallbackTable = table
    		GetEntityNeighborsScriptedOnly = temp
    	end
    	return result_table, special
    end

    The game crashes only if there are these zones on the next and on the previous map.
    I think that after loading next map, it does not remove hidden objects. 
    How to remove them?

  4. 3 hours ago, Slastraf said:

    you can make animated textures in leadwerks, use the shader from the firepit addon or if you have your own one. But you would need a n*n spritesheet

     

    I don't need a sprite. I need to move the texture on brush. Just move, I can using shaders. But, using the script, get material, and then set shader for material, this fails. 
    And to solve the second problem, I just need to learn how to get material from brush(Box,Wedge,Sphere etc.). 

  5. Quote

    maybe the character controller and other object have different mass to them

    No. I changed mass of objects, result is same. I need this to be independent of the mass.
     

    Quote

    physicsSetPosition

    I'm honest. Didn't know.
    But I tried, the result is not what you need. Object with a Rigid Body, flew somewhere, and with Character Controller stands still.
     

    Quote

    For the shader thing, please explain better what u need, it probably dont need to be scripted. Check out firepit addon in workshop for animated sprite texture

    I just need the texture on the brush to move at the right speed. As in Half-Life for example. 
    In entity script, set speed and direction of the texture for shader.
    But, as I understand it, the texture of the brush is not so easy to take. (self.entity:GetMaterial() == nil). 

    P.S. My English is bad and i'm partly using Google Translate for writing post. (<- Этот текст я написал без использования переводчика)

     

    hl.gif

  6. However, not everything works so well. The speed of objects with different Physical Mode on conveyor are always different (Rigid Body goes faster than the Character Controller). How can they be equated?

    And another question. How to load a brush entity shader? (just... 

    local mat = self.entity:GetMaterial()
    mat:SetShader(self.shader) --attempt to index local 'mat' (a nil value)
    

    ) This is necessary to make the texture move.

  7. It turned out the problem in speed. 
    Replaced self.speed=Vec3(5,0,0) on self.speed=Vec3(3(or below),0,0). And somehow the problem disappeared.

    How to delete a post?

    • Thanks 1
  8. I'm trying to make a conveyor. But faced a problem.

    function Script:Collision(entity, position, normal, speed)
    	if self.active then
    		entity:SetVelocity(self.speed) --self.speed=Vec3(5,0,0)
    	end
    end

    It seems to work. But when the object goes in the opposite direction, its speed is the same as if it did not go on conveyor.
    I tried using AddForce. But it is too fast (values below 0.04 (self.speed=Vec3(0.04,0,0)) do not move the object, and above is very fast).
     

  9. 2 minutes ago, Slastraf said:

    Call needs to be a global function. So far  you have Call in the Script as a local function. To make it global paste it in main.lua  , maybe somewhere at the top :

    
    function Call(entity,extra) --not use function Script:... because it is a global function
    	System:Print("See "..tostring(entity:GetKeyValue("name")))
    end

     

    Thanks.It helped.

  10. -=END=-
    AABB not see entity

    I copied code in:


    It turned out somehow so :

    function Script:Call(entity,extra)
        self.see=true
    	System:Print("see")
    end
    
    function Script:UpdatePhysics()
    	local position = self.entity:GetPosition(true)
    	local aabb = AABB()
    	aabb.min.x=position.x-30
    	aabb.min.y=position.y-30
    	aabb.min.z=position.z-30
    	aabb.max.x=position.x+30
    	aabb.max.y=position.y+30
    	aabb.max.z=position.z+30  
    	aabb:Update()
    	self.entity.world:ForEachEntityInAABBDo(aabb,"Call", self.entity)
    end

    But at the approach of any other object(e.g. the player) to this object, nothing happens.

    -=RUS=-
    AABB не видит объекты.

    Я взял код из 


    Получилось как-то так :
     

    function Script:Call(entity,extra)
        self.see=true
    	System:Print("see")
    end
    
    function Script:UpdatePhysics()
    	local position = self.entity:GetPosition(true)
    	local aabb = AABB()
    	aabb.min.x=position.x-30
    	aabb.min.y=position.y-30
    	aabb.min.z=position.z-30
    	aabb.max.x=position.x+30
    	aabb.max.y=position.y+30
    	aabb.max.z=position.z+30  
    	aabb:Update()
    	self.entity.world:ForEachEntityInAABBDo(aabb,"Call", self.entity)
    end

    Но при подходе любого другого объекта(например, игрок) к этому объекту, ничего не происходит. 

×
×
  • Create New...