PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : SENT Gravitationsdämpfer



WeltEnSTurm
12.04.2008, 13:40
Ich wünsche mir..
Ein SENT!
Es soll 2 wire Inputs haben...
On
und..
Air Resistance!
Wenn On 1 ist, soll er alle props die rangeweldet sind schwerelos machen (-> Grav Toggle 0)
Und Air Resistance sollte von 0 bis 100 gehen, bei 100 kann man die contraption kaum bewegen.
Und am schönsten wärs wenn noch ein tut dazukommt :D
Danke.
Oder nur das Tut, ich würds gern mal selber versuchen :)

Specter123
12.04.2008, 13:47
Kann man Grav toggle 0 auch in die Konsole eingeben? Und wird dann alles auch schwerelos? Wäre ja voll cool, und als Sent noch besser.

WeltEnSTurm
12.04.2008, 13:50
Kann man Grav toggle 0 auch in die Konsole eingeben? Und wird dann alles auch schwerelos? Wäre ja voll cool, und als Sent noch besser.

Du kannst mit dem tool "Physical Properties" den haken bei "Gravety Toggle" wegmachen, alles was du damit anschießt wird schwerelos.

WeltEnSTurm
13.04.2008, 18:52
Bitte D:
(wenigstens sagen ob ihrs interresant finden würdet)
http://www.garrysmod.org/img/?t=dll&id=31953 (http://www.garrysmod.org/downloads/?a=view&id=31953)
Vielleicht hilft das, ist das Airbrake Tool

WeltEnSTurm
03.05.2008, 22:33
Es ist mir peinlich, aber..

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )


function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( "GravToggleController" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent
end

self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self:CreateWireInputs("Activate");
self:CreateWireOutputs("Active");


Weiter weiß ich nicht
Sollte fürs erste nur GravToggle für alle rangeweldeten Props sein.
Ich brauch eure hilfe :(

WeltEnSTurm
05.05.2008, 20:56
Wird das jetzt mein Doppelpost-Thread? D:
Ich hab die Funktion für gravtoggle gefunden (physprop tool)

// Get client's CVars
local gravity = util.tobool( self:GetClientNumber( "gravity_toggle" ) )
local material = self:GetClientInfo( "material" )

// Set the properties

construct.SetPhysProp( self:GetOwner(), Ent, Bone, nil, { GravityToggle = gravity, Material = material } )
Wäre mal nett, wenn mir einer hefen könnte.

WeltEnSTurm
06.05.2008, 15:31
Lol.
Kann das so funktionieren?

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( "GravToggleController" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent
end



self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self:CreateWireInputs("Activate");
gravity = util.tobool( self:GetClientNumber( "gravity_toggle" ) )

function ENT:TriggerInput(k,v)
if(k == "Activate") then
gravity = Activate
return true
end
end

Fun47
06.05.2008, 16:00
warum versuchst du es nicht einfach ? ;)

WeltEnSTurm
08.05.2008, 19:11
http://img231.imageshack.us/img231/7227/gmconstruct0018cw8.jpg
Wenigstens passiert etwas wenn ich es spawne :gmod:

Ahab
08.05.2008, 22:58
sieht aus wie der schatten von so nem error teil :gmod:

monky2k6
08.05.2008, 23:24
Wieso schaltest du die Schwerkraft so kompliziert ab? :V

Geht viel leichter:
http://wiki.garrysmod.com/wiki/?title=PhysObj.EnableGravity

Machst einfach:
ent:GetPhysicsObject():EnableGravity( false )
und die Schwerkraft für das Objekt ist deaktiviert.

ALL YOU CAN EAT
09.05.2008, 05:46
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
ENT.radius = 100
ENT.mode = 1
ENT.nextUseTime = CurTime()
ENT.ents = {}
function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( "sent_lowgrav" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent

end


/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

// Use the helibomb model just for the shadow (because it's about the same size)
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )

// Don't use the model's physics - create a sphere instead
self.Entity:PhysicsInitSphere( 16, "metal_bouncy" )

// Wake the physics object up. It's time to have fun!
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end

// Set collision bounds exactly
self.Entity:SetCollisionBounds( Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) )

end


/*---------------------------------------------------------
Name: PhysicsCollide
---------------------------------------------------------*/
function ENT:PhysicsCollide( data, physobj )

// Play sound on bounce
if (data.Speed > 80 && data.DeltaTime > 0.2 ) then
self.Entity:EmitSound( "Rubber.BulletImpact" )
end

// Bounce like a crazy bitch
local LastSpeed = data.OurOldVelocity:Length()
local NewVelocity = physobj:GetVelocity()
NewVelocity:Normalize()

LastSpeed = math.max( NewVelocity:Length(), LastSpeed )

local TargetVelocity = NewVelocity * LastSpeed * 0.9

physobj:SetVelocity( TargetVelocity )

end

/*---------------------------------------------------------
Name: OnTakeDamage
---------------------------------------------------------*/
function ENT:OnTakeDamage( dmginfo )

// React physically when shot/getting blown
self.Entity:TakePhysicsDamage( dmginfo )

end


/*---------------------------------------------------------
Name: Use
---------------------------------------------------------*/
function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
if self.nextUseTime > CurTime() then return end
self.nextUseTime = CurTime()+0.2
if self.mode == 0 then
activator:PrintMessage(3, "Mode: Disable Gravity")
self.mode = 1
elseif self.mode == 1 then
activator:PrintMessage(3, "Mode: Enable Gravity")
self.mode = 0
end
end
end
function ENT:IsInTable(Table, WhatToFind)
local Return = false
for k,v in pairs(Table) do
if v == WhatToFind then
Return = true
end
end
return Return
end
function ENT:Check()
local find = ents.FindInSphere(self.Entity:GetPos(),self.radius )
for k,v in pairs( self.ents ) do
if not self:IsInTable(find, v) then
if v and v:IsValid() then
local phys = v:GetPhysicsObject();
if phys:IsValid() then
phys:EnableGravity( true )
phys:Wake()
end
end
table.remove(self.ents,k)
end
end
end
function ENT:OnRemove()
for k,v in pairs( self.ents ) do
if v and v:IsValid() then
local phys = v:GetPhysicsObject()
if phys:IsValid() then
phys:EnableGravity(true)
phys:Wake();
end
end
end
end
function ENT:Think()
self:Check()
local find = ents.FindInSphere( self.Entity:GetPos(), self.radius )
for k,v in pairs( find ) do
local entphys = v:GetPhysicsObject();
if entphys:IsValid() then
if self.mode == 1 then
self.Entity:GetPhysicsObject():EnableGravity( false )
self.Entity:GetPhysicsObject():Wake()
if self.ents[k] != v and tostring(v:GetClass()) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
self.ents[k] = v
end
if tostring(v:GetClass( )) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
entphys:EnableGravity( false )
entphys:Wake()
end
elseif self.mode == 0 then
self.Entity:GetPhysicsObject():EnableGravity( true )
self.Entity:GetPhysicsObject():Wake()
if tostring(v:GetClass( )) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
entphys:EnableGravity( true )
entphys:Wake()
end
end
end
end
end


Meinst du sowas in der art ?

Pac_187
09.05.2008, 10:18
Was soll denn das Zeug in Zeile 141 und 142?

-----

Desweiteren hast du den Bouncing-Ball Code kopiert,
welcher dein SENT noch dazu bringt zu springen xD

WeltEnSTurm
09.05.2008, 10:31
Danke, dass mal jemand hilft :D


Wieso schaltest du die Schwerkraft so kompliziert ab? :V

Geht viel leichter:
http://wiki.garrysmod.com/wiki/?title=PhysObj.EnableGravity

Machst einfach:
ent:GetPhysicsObject():EnableGravity( false )
und die Schwerkraft für das Objekt ist deaktiviert.
Weil ich in garry's physprop script gesucht hab :gmod:

WeltEnSTurm
10.05.2008, 10:36
Ich denke, dass ich es nicht spawnen kann (oder nicht richtig)
liegt an der cl_init.
Wie sollte sie am besten aussehen?
Das funktioniert nicht: (von GCombat-SENT's)
include('shared.lua')
//[[---------------------------------------------------------
//Name: Draw Purpose: Draw the model in-game.
//Remember, the things you render first will be underneath!
//-------------------------------------------------------]]
function ENT:Draw()
// self.BaseClass.Draw(self)
-- We want to override rendering, so don't call baseclass.
// Use this when you need to add to the rendering.
self.Entity:DrawModel() // Draw the model.
end

ALL YOU CAN EAT
10.05.2008, 11:49
so sollte es gehen

include('shared.lua')

local matBall = Material( "sprites/sent_ball" )

/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

local i = math.random( 0, 3 )

if ( i == 0 ) then
self.Color = Color( 255, 0, 0, 255 )
elseif ( i == 1 ) then
self.Color = Color( 0, 255, 0, 255 )
elseif ( i == 2 ) then
self.Color = Color( 255, 255, 0, 255 )
else
self.Color = Color( 0, 0, 255, 255 )
end

end


/*---------------------------------------------------------
Name: DrawPre
---------------------------------------------------------*/
function ENT:Draw()

local pos = self.Entity:GetPos()
local vel = self.Entity:GetVelocity()

render.SetMaterial( matBall )

local lcolor = render.GetLightColor( pos ) * 2
lcolor.x = self.Color.r * mathx.Clamp( lcolor.x, 0, 1 )
lcolor.y = self.Color.g * mathx.Clamp( lcolor.y, 0, 1 )
lcolor.z = self.Color.b * mathx.Clamp( lcolor.z, 0, 1 )


for i = 1, 10 do

local col = Color( lcolor.x, lcolor.y, lcolor.z, 200 / i )
render.DrawSprite( pos + vel*(i*-0.005), 32, 32, col )

end

render.DrawSprite( pos, 32, 32, lcolor )



end

Pac_187
10.05.2008, 12:12
Ahahahah xD

ALL YOU CAN EAT halte dich doch bitte aus dem Thread raus...

Copy 'n Paste vom Bouncyball cl_init.lua ist kein Beweis dafür wie sie
auszusehen hat!


Lern lieber erstmal ein wenig bevor du anderen Leuten hilfst,
denn mit dem Wissensstand bringst du die Leute nur durcheinander.

Versuch überhaupt erstmal zu verstehen was du da gerade geposted hast.

-----


@WeltenSturm:

So wie du sie jetzt hast ist es richtig es soll ja nur das SENT angezeigt werden ( also Model davon ) und das reicht ja schon.


Bekommst du denn sonst noch irgendwo, irgendwelche Fehler?

WeltEnSTurm
10.05.2008, 20:39
Wenn ich eine andere cl_init verwende, kommt der fehler nicht :-?
http://img170.imageshack.us/img170/5192/gmmulticonstruct0000pm5.jpg

WeltEnSTurm
11.05.2008, 08:42
Das hab ich jetzt gelöst (von GravToggleController auf gravtogglecontroller umbenennen xD)
Aber ingame gibt er mir einen LUA-Fehler an (schreibt er komischerweise nicht in die console)
(ohne Bouncy-ball Scheiß) nach der 60ten Zeile (63 oder so) schreibt er "then expected near ;"

Aber der code ist mir sowieso zu kompliziert.
Wie kann man die gravitation für alle constrainten sachen verändern?
Und ist an dem etwas falsch?

self.CreateWireInputs("Activate")


if "Activate" == 1
then ent:GetPhysicsObject():EnableGravity( true )
else ent:GetPhysicsObject():EnableGravity( false )
end

Andrey
11.05.2008, 09:43
self.CreateWireInputs("Activate")


if "Activate"
then ent:GetPhysicsObject():EnableGravity( true )
else ent:GetPhysicsObject():EnableGravity( false )
end

Fehlt da nicht ein End?
Ich kenn mich kaum aus mit Lua, aber ich glaube es fehlt ein End.

Außerdem ist der "== 1" eh überflüssig. (oder?)

Hab das mal rausgenohmen.

WeltEnSTurm
11.05.2008, 11:20
Wenn ich meins benütze kann ich ein Error spawnen,
mit deinem garnichts :-?

Pac_187
11.05.2008, 11:23
Eine if then else end Funktion solltest du am besten so aufschreiben:


if "Activate" == 1 then
ent:GetPhysicsObject():EnableGravity( true )
else
ent:GetPhysicsObject():EnableGravity( false )
end


Das ist:

1. Übersichtlicher und
2. musst du nicht alles mit ; trennen und in eine Zeile schreiben.

WeltEnSTurm
11.05.2008, 12:10
http://img153.imageshack.us/img153/9760/gmconstruct0027ge1.jpg
Wenn ich spawne kommt noch das:
entities/gravtogglecontroller/init.lua:19: attempt to index global 'self' (a nil value)
Deswegen auch der Error :-?
Wartet, ich hab den Fehler gefunden.
Aber jetzt kommt:

entities/gravtogglecontroller/init.lua:19: '<name>' expected near ':'
Folder = entities/gravtogglecontroller
Couldn't register Scripted Entity gravtogglecontroller - the Type field is empty!
Doppelpost:
Fehler behoben.
Aber es kommen immer neue :P
Ich kann das sent schon spawnen, aber nicht angreifen oder berühren.
http://img153.imageshack.us/img153/2816/gmconstruct0029it4.jpg

Der

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent
end

function ENT:Initialize ()
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self:CreateWireInputs("Activate");
end

if "Activate" == 1 then
ent:GetPhysicsObject():EnableGravity( false )
else
ent:GetPhysicsObject():EnableGravity( true )
end

function ENT:OnRemove()
for k,v in pairs( self.ents ) do
if v and v:IsValid() then
local phys = v:GetPhysicsObject()
if phys:IsValid() then
phys:EnableGravity(true)
phys:Wake();
end
end
end
end

Argh, ich sehe gerade, dass ich statt
self.CreateWireInputs
self:CreateWireInputs
geschrieben habe.

A.I.
11.05.2008, 13:13
Der

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 16

local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()

return ent --Ich weis nicht, ob ich Recht habe, aber irgendwie ist "ent" hier falsch.
end

function ENT:Initialize ()
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self:CreateWireInputs("Activate");
end

if "Activate" == 1 then
ent:GetPhysicsObject():EnableGravity( false )
else
ent:GetPhysicsObject():EnableGravity( true )
end

function ENT:OnRemove()
for k,v in pairs( self.ents ) do
if v and v:IsValid() then
local phys = v:GetPhysicsObject()
if phys:IsValid() then
phys:EnableGravity(true)
phys:Wake();
end
end
end
end

WeltEnSTurm
11.05.2008, 13:25
Ich hab die physics initialize vergessen.
Wenn ich spawne:
entities/gravtogglecontroller/init.lua:29: attempt to index global 'ent' (a nil value)

http://img153.imageshack.us/img153/3922/keksro2.jpg
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize ()
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
local phys = self.Entity:GetPhysicsObject()

self.CreateWireInputs("Activate")
end

if "Activate" == 1 then
ent:GetPhysicsObject():EnableGravity( false )
else
ent:GetPhysicsObject():EnableGravity( true )
end

function ENT:OnRemove()
for k,v in pairs( self.ents ) do
if v and v:IsValid() then
local phys = v:GetPhysicsObject()
if phys:IsValid() then
phys:EnableGravity(true)
phys:Wake();
end
end
end
end

@ A.I. :
ent gehört da hin.

A.I.
11.05.2008, 13:31
Er muss ja wissen, was passiert, wenn man ihn behührt:

http://wiki.garrysmod.com/wiki/?title=ENT.Touch

In deinem Fall:

function ENT:Touch( hitEnt )
if hitEnt:IsValid() && hitEnt:IsPlayer() then
end
end


+ Das fehlt noch:

http://wiki.garrysmod.com/wiki/?title=ENT.KeyValue
http://wiki.garrysmod.com/wiki/?title=ENT.UpdateTransmitState

Das Trasmit ist für Multiplayer

WeltEnSTurm
12.05.2008, 17:41
Ach, es will nicht funktionieren..

WeltEnSTurm
14.05.2008, 11:38
Ich versuch mal, irgendwie ENT:starttouch und endtouch einzubauen.
€:
Cool, wenn ich spawne krieg ich keinen Fehler.
Aber wenn ich das SEnt spawne:
http://img441.imageshack.us/img441/5679/gmconstruct0039ee6.th.jpg (http://img441.imageshack.us/my.php?image=gmconstruct0039ee6.jpg)

humanexecuter
14.05.2008, 13:25
Da ist irgendwas bei den WireInputs falsch.
Bekomm ich mal bitte deinen Jetzigen Lua Code ? :-)

A.I.
14.05.2008, 13:46
Ich versuch mal, irgendwie ENT:starttouch und endtouch einzubauen.
€:
Cool, wenn ich spawne krieg ich keinen Fehler.
Aber wenn ich das SEnt spawne:
http://img441.imageshack.us/img441/5679/gmconstruct0039ee6.th.jpg (http://img441.imageshack.us/my.php?image=gmconstruct0039ee6.jpg)

Öhh

Dein SENT hat keine Physik.

Die musst du noch hinzufügen.

WeltEnSTurm
14.05.2008, 16:25
Öhh

Dein SENT hat keine Physik.

Die musst du noch hinzufügen.
Aber wie?
Komisch..
€:
ich habs.
Mal testen :gmod:

Ich hab aVoN's cloacing gen verwendet.
Gibt noch ein paar unnütze STool-parts.

AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");
--ENT.Sounds = {Hit=Sound("GTCon.mp3")};
ENT.NoDissolve = true;
ENT.CDSIgnore = true; -- CDS Immunity
function ENT:gcbt_breakactions() end; ENT.hasdamagecase = true; -- GCombat invulnarability!

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()
self.Size = self.Size or 300;
self.Parent = self.Entity:GetParent();
self.Entity:SetModel(self.Models.Base);
self.Entity:PhysicsInit(SOLID_VPHYSICS);
self.Entity:SetMoveType(MOVETYPE_VPHYSICS);
self.Entity:SetSolid(SOLID_VPHYSICS);
self.Entity:SetNotSolid(true);
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self:CreateWireInputs ("Activate");
local phys = self.Entity:GetPhysicsObject();
if(phys:IsValid()) then
phys:Wake();
phys:SetMass(10);
end
end

function ENT:UpdateTransmitState() return TRANSMIT_ALWAYS end;

function ENT:TriggerInput(k,v)
if(k=="Activate") then
if((v or 0) >= 1) then
self:Status(true);
else
self:Status(false);
end
end
end

function ENT:Use(p)
if(self:Enabled()) then
self:Status(false);
else
self:Status(true);
end
end

function ENT:StartTouch(e)
if(self.Size == 1) then return end;
if(not ValidEntity(e)) then return end;
if(self.NoCollide[e]) then return end;
end


function ENT:EndTouch(e)
if(self.Size == 1) then return end;
if(not ValidEntity(e)) then return end;
if(not self.NoCollide[e]) then return end;
end

function ENT:ControlGravety()
if (not self:Enabled ()) then
ent:GetPhysicsObject():EnableGravity( true )
else
ent:GetPhysicsObject():EnableGravity( false )
end
end

function ENT:OnRemove()
self.StartTouch = function() end;
self.EndTouch = function() end;
ent:GetPhysicsObject():EnableGravity(true)
end

humanexecuter
14.05.2008, 16:36
Lieber WeltenSturm,
dürfte ich dein Script benutzen , wovon die meisten hier ja mitgeholfen haben :P

WeltEnSTurm
14.05.2008, 16:39
Nein, weil es nicht funktioniert, und ich das letzte gepostete selbst zusammengestellt habe.
http://img108.imageshack.us/img108/3143/gmmulticonstruct0016rp9.jpg
Siehst du.
BTW, ich hab den Fehler gefunden.

A.I.
14.05.2008, 16:44
function ENT:Initialize()

self.Entity:SetModel( "models/props_interiors/BathTub01a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox

local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end


€: I'm FAILed.

WeltEnSTurm
14.05.2008, 16:46
Schau mal in meinen neuesten Versuch, da steht es doch drin. ;)

I wanna make stool now.

A.I.
14.05.2008, 22:33
hmm..

Hast du dir das Wire Base Entity angeschaut?
Bei dir fehlt etwas, was hier steht. :-?



include("shared.lua")

ENT.RenderGroup = RENDERGROUP_TRANSLUCENT//RENDERGROUP_OPAQUE//RENDERGROUP_BOTH

function ENT:Draw()
self:DoNormalDraw()
Wire_Render(self.Entity)
end

function ENT:DoNormalDraw()
local e = self.Entity;
if (LocalPlayer():GetEyeTrace().Entity == e and EyePos():Distance(e:GetPos()) < 256) then
if ( self.RenderGroup == RENDERGROUP_OPAQUE) then
self.OldRenderGroup = self.RenderGroup
self.RenderGroup = RENDERGROUP_TRANSLUCENT
end
self:DrawEntityOutline(1.0)
self.Entity:DrawModel()
if(self:GetOverlayText() ~= "") then
AddWorldTip(e:EntIndex(),self:GetOverlayText(),0.5 ,e:GetPos(),e)
end
else
if(self.OldRenderGroup) then
self.RenderGroup = self.OldRenderGroup
self.OldRenderGroup = nil
end
e:DrawModel()
end
end

function ENT:Think()
if (CurTime() >= (self.NextRBUpdate or 0)) then
self.NextRBUpdate = CurTime() + math.random(30,100)/10 --update renderbounds every 3 to 10 seconds
Wire_UpdateRenderBounds(self.Entity)
end
end





ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Wire Entity"
ENT.Author = "Erkle"
ENT.Contact = "[email protected]"
ENT.Purpose = "Base for all wired SEnts"
ENT.Instructions = ""
ENT.Spawnable = false
ENT.AdminSpawnable = false
ENT.IsWire = true

function ENT:GetOverlayText()
local name = self.Entity:GetNetworkedString("WireName")
//local txt = self.BaseClass.BaseClass.GetOverlayText(self) or ""
local txt = self.Entity:GetNetworkedBeamString("GModOverlayText") or ""
if (not SinglePlayer()) then
local PlayerName = self:GetPlayerName()
txt = txt .. "\n(" .. PlayerName .. ")"
end
if(name and name ~= "") then
if (txt == "") then
return "- "..name.." -"
end
return "- "..name.." -\n"..txt
end
return txt
end





AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

ENT.WireDebugName = "No Name"
function ENT:Think()
if(not Wire_DisableOverlayTextUpdate and self.NextOverlayTextTime and CurTime() >= self.NextOverlayTextTime) then
if(self.NextOverlayText) then
//self.BaseClass.BaseClass.SetOverlayText(self, self.NextOverlayText)
self.Entity:SetNetworkedBeamString("GModOverlayText",self.NextOverlayText)
self.NextOverlayText = nil
self.NextOverlayTextTime = CurTime() + (self.OverlayDelay or 0.4) + math.random()*(self.OverlayRandom or 0.2)
if(Wire_SlowerOverlayTextUpdate) then
self.NextOverlayTextTime = self.NextOverlayTextTime + 1 //add a sec between updates
end
else
self.NextOverlayText = nil
self.NextOverlayTextTime = nil
end
end
end

function ENT:SetOverlayText(txt)
if(Wire_DisableOverlayTextUpdate) then return end
if(Wire_FastOverlayTextUpdate) then
self.Entity:SetNetworkedBeamString("GModOverlayText",txt,true) //send it now, damn it!
else
if(self.NextOverlayTextTime) then
self.NextOverlayText = txt
else
self.Entity:SetNetworkedBeamString("GModOverlayText",txt)
self.NextOverlayText = nil
if(not self.OverlayDelay or self.OverlayDelay > 0 or Wire_SlowerOverlayTextUpdate or not SinglePlayer() or Wire_ForceDelayOverlayTextUpdate) then
self.NextOverlayTextTime = CurTime() + (self.OverlayDelay or 0.6) + math.random()*(self.OverlayRandom or 0.2)
end
end
end
end

function ENT:OnRemove()
Wire_Remove(self.Entity)
end

function ENT:OnRestore()
Wire_Restored(self.Entity)
end

function ENT:BuildDupeInfo()
return WireLib.BuildDupeInfo(self.Entity)
end

function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
WireLib.ApplyDupeInfo( ply, ent, info, GetEntByID )
end

function ENT:PreEntityCopy()
//build the DupeInfo table and save it as an entity mod
local DupeInfo = self:BuildDupeInfo()
if(DupeInfo) then
duplicator.StoreEntityModifier(self.Entity,"WireDupeInfo",DupeInfo)
end
end

function ENT:PostEntityPaste(Player,Ent,CreatedEntities)
//apply the DupeInfo
if(Ent.EntityMods and Ent.EntityMods.WireDupeInfo) then
Ent:ApplyDupeInfo(Player, Ent, Ent.EntityMods.WireDupeInfo, function(id) return CreatedEntities[id] end)
end
end

WeltEnSTurm
05.07.2008, 16:22
Wisst ihr was gefehlt hat?
include('entities/base_wire_entity/init.lua');
:P

Edit:
In der shared.lua muss auch stehen: ent.base = "base_gmodentity"

Einen Fehler hat das noch, wenn ich es zu wiren versuche:


entities/gravtogglecontroller/init.lua:41: attempt to index global 'ent' (a nil value)


Der

AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include('entities/base_wire_entity/init.lua');
include("shared.lua");
ENT.NoDissolve = true;
ENT.CDSIgnore = true;
function ENT:gcbt_breakactions() end; ENT.hasdamagecase = true;

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()

self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" );

self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox

local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
self.Inputs = Wire_CreateInputs( self.Entity, { "Activate" } )
end

function ENT:UpdateTransmitState() return TRANSMIT_ALWAYS end;

function ENT:TriggerInput(iname, value)
if(iname == "Activate") then
if((value or 0) >= 1) then
ent:GetPhysicsObject():EnableGravity(false)
else
ent:GetPhysicsObject():EnableGravity(true)
end
end
end

function ENT:PhysicsUpdate( physobj )
end

function ENT:OnRemove()
ent:GetPhysicsObject():EnableGravity(true)
end

monky2k6
05.07.2008, 17:30
Guck doch in die Zeile.

Da passiert was mit dem "ent".
"Ent" ist aber nicht deklariert in dieser Funktion, bzw. es gibt keine globale Variable namens "Ent".

Ich blick gerade nicht ganz durch, aber versuch mal folgendes:


function ENT:TriggerInput(iname, value)
local ent = self.Entity


Ich weiß ja nicht was "ent" sein soll also weiß ich auch nicht womit man es deklarieren muss, aber versuch das nun einfach mal.

WeltEnSTurm
05.07.2008, 17:41
Ich will aber nicht, dass nur das Entity schwerelos wird, es soll auch alles was rangeweldet ist schwerelos werden.

Andrey
05.07.2008, 18:17
Ich will aber nicht, dass nur das Entity schwerelos wird, es soll auch alles was rangeweldet ist schwerelos werden.

Der Advanced Duplicator, hatte mal eine Funktion, die alles Rangeweldete/Geropete u.s.w. mit genohmen hatte.

WeltEnSTurm
05.07.2008, 18:27
Der Advanced Duplicator, hatte mal eine Funktion, die alles Rangeweldete/Geropete u.s.w. mit genohmen hatte.

Hatte? :gmod:
Mal schaun.
Ich hab übrigens rausgefunden wie man ne airbrake macht :D

ReEdit:

Jetzt geht alles, (wireinputs, schwerelos) nur will die airbrake funktion nicht funktionieren.
Und irgendwie überblicke ich den advdupe code nicht.


AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include('entities/base_wire_entity/init.lua');
include("shared.lua");

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()

self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" );

self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox

local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
self.Inputs = Wire_CreateInputs( self.Entity, { "Activate" , "Airbrake" } )
end

function ENT:UpdateTransmitState() return TRANSMIT_ALWAYS end;

function ENT:TriggerInput(iname, value)
local ent = self.Entity
if(iname == "Activate") then
if((value or 0) >= 1) then
ent:GetPhysicsObject():EnableGravity(false)
else
ent:GetPhysicsObject():EnableGravity(true)
end
end
if(iname == "Airbrake") then
self.passive = value
end
end

function ENT:PhysicsUpdate( physobj )
local vel = physobj:GetVelocity()
if self.passive and self.passive > 0 then
if self.passive > 100 then self.passive = 100 end

vel = vel * ((100.0 - self.passive)/100.0)
end

physobj:SetVelocity(vel)
end

function ENT:OnRemove()
local ent = self.Entity
ent:GetPhysicsObject():EnableGravity(true)
end

Keks:
BLARGH


includes/modules/constraint.lua:1625: attempt to index local 'ent' (a function value)



AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include('entities/base_wire_entity/init.lua');
include("shared.lua");

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( "gravtogglecontroller" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()

self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" );
self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox

local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
self.Inputs = Wire_CreateInputs( self.Entity, { "Activate" , "Airbrake" } )
end

function ENT:UpdateTransmitState() return TRANSMIT_ALWAYS end;

function ENT:TriggerInput(iname, value)
local ConstrainedEntities = constraint.GetAllConstrainedEntities( Entity )
if(iname == "Activate") then
for _, ent in pairs( ConstrainedEntities ) do
if((value or 0) >= 1) then
constr.Entity:GetPhysicsObject():EnableGravity(fal se)
else
constr.Entity:GetPhysicsObject():EnableGravity(tru e)
end
end
end
if(iname == "Airbrake") then
self.passive = value
end
end

function ENT:PhysicsUpdate( physobj )
local vel = physobj:GetVelocity()
if self.passive and self.passive > 0 then
if self.passive > 100 then self.passive = 100 end

vel = vel * ((100.0 - self.passive)/100.0)
end

physobj:SetVelocity(vel)
end

function ENT:OnRemove()
constr.Entity:GetPhysicsObject():EnableGravity(tru e)
end

Happy_Killer
06.07.2008, 01:11
wirst du das sent public stellen? :D

Also ich finde du hast das gut hinpinökelt bislang ;)
Du solltest dir noch n model suchen das gut passt :lol:


PS: könntest du mir mal deinen stargate skin schicken? oder wirst du das auch noch public machen

WeltEnSTurm
06.07.2008, 11:28
Col Sheppard arbeitet gerade an einem Model, ich hoffe wir finden jemanden, der es compiliert.

Es läuft alles perfekt (Airbrake auch :D)
Nur hab ich keine ahnung, wie ich das einbinden soll, damit nicht nur das SENT, sondern auch alles constrainte schwerelos/zur airbrake wird.

local ConstrainedEntities = constraint.GetAllConstrainedEntities( Entity )

// Loop through all the entities in the system
for _, ent in pairs( ConstrainedEntities ) do
// constr.Constraint is the actual constraint.
// constr.Entity is a table of each Entity connected to the constraint.
// it includes these items.
// constr.Entity[1].Index number
// constr.Entity[1].Entity entity
// constr.Entity[1].Bone number
// constr.Entity[1].LPos vector
// constr.Entity[1].WPos vector
// constr.Entity[1].Length number
// constr.Entity[1].World boolean
end
Doppelpost:
Ich habe fertig.
Soll ich nen eigenen Thread im Releases machen?