|
| 30 Dec 2014 12:06 AM |
so basically here where i've gotten in one hour
function wingani() local player = player local mouse = player:GetMouse()
function CalculateOffset() local offset = {} offset.X = mouse.X - mouse.ViewSizeX/2 offset.Y = mouse.Y - mouse.ViewSizeY/2 end
while true do wait() local offset = CalculateOffset()
end
CalculateOffset() end
This code goes into a localscript basically the X offset Manipulates the movements of the left and right Ailerons and Y offsets Manipulates the movements of the elevators up or down. can anyone help me finish the last section
i think i can use this CFrame.fromEulerAnglesXYZ but i'm not sure. i've been stuck here for hours i'm willing to pay. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 12:08 AM |
'local player = player'
-_-
'CalculateOffset()'
-_-
'while true do wait() local offset = CalculateOffset()
end'
-_-
|
|
|
| Report Abuse |
|
|
| |
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:18 AM |
local player = player ???
I'm new at scripting so I might be wrong, but shouldn't it be;
local player = game.Players.LocalPlayer
|
|
|
| Report Abuse |
|
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:21 AM |
And,
while wait() do
instead of; while true do wait() -- If that's what you were trying to do. You could also do, while true do wait(), not sure if it's the same thing. |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:23 AM |
@people above
This probably isn't his full script, he most likely defined player above.
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:25 AM |
@Pihs, it looks like he's showing us his defining, since he's saying local player = player
why would he define player twice? Wouldn't make sense.
If he did define player before as; game.Players.LocalPlayer, he's pretty much saying
game.Players.LocalPlayer = game.Players.LocalPlayer. :P |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:26 AM |
'local' versus regular 'player'
Use that small brain you have before trying to counter what I was saying.
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:27 AM |
Sorry, i'm bad at explaining, what I mean is that he left "player" alone. If it was something like; player.(something), then it'd make sense. |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:27 AM |
Especially since you're new at scripting.
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:27 AM |
| Okay, i'm new at scripting so I didn't know, but thanks. I now know something new. |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:28 AM |
The original poster probably is just a tad inefficient, so he defined things multiple times.
I did that when I first started.
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 12:29 AM |
Yeah player was defined already
function CalculateOffset() local offset = {} offset.X = mouse.X - mouse.ViewSizeX/2 offset.Y = mouse.Y - mouse.ViewSizeY/2 end
while true do wait() local offset = CalculateOffset() ----- Right here is where i need help X manipulates left and right wing and Y manipulates tail movements. my question is how would i finish this function so if i move my mouse to the left wing moves down and right wing aileron moves up vise verso for tail end
CalculateOffset() end |
|
|
| Report Abuse |
|
|
BamRulez
|
  |
| Joined: 18 Sep 2010 |
| Total Posts: 239 |
|
|
| 30 Dec 2014 12:30 AM |
Sorry Phils, I didn't mean to argue with you. I just though that if he needed our help, he would've posted the whole script. But, sorry. |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:30 AM |
oh, nvm about inefficient.
Did you try searching the wiki?
This isn't necessarily my area of code, I usually make guis and such.
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 12:33 AM |
-- this is the whole script
local players = game:GetService("Players") local player = players.LocalPlayer local cam = game.Workspace.CurrentCamera local plane = script.Plane.Value script.Plane:Destroy() local gui = script.PlaneGui:Clone() script.PlaneGui:Destroy()
local health = plane.Health local maxHealth = math.abs(health.Max.Value) if (maxHealth == 0) then maxHealth = 1 end local dead = false
local mouse = player:GetMouse() local custom = plane.Customize
local maxThrust = 0 local thruster,gyro
local doPushback = false
-- Small optimization help: local CFNEW = CFrame.new local CFANG = CFrame.Angles local V3NEW = Vector3.new local RAD = math.rad local FLOOR = math.floor
-- Operationals local op = (function() local o = plane.Operational local t = { seat = o.MainSeat; landingGear = o.LandingGear; main = o.Main; flying = true; flyingStopped = false; } return t end)();
-- Load customized plane properties: local properties = { maxSpeed = custom.MaxSpeed.Value; desiredSpeed = 0; -- Actual speed of the plane; manipulated by throttle input spdIncRate = custom.MaxSpeed.IncreaseRate.Value; autoLandingGear = custom.AutoLandingGear.Value; fadeLandingGear = custom.FadeLandingGear.Value; groupSpecific = {custom.GroupSpecific.Value,custom.GroupSpecific.GroupID.Value}; planeName = custom.PlaneName.Value; teamSpecific = {custom.TeamSpecific.Value,custom.TeamSpecific.TeamColor.Value}; thrustRatio = custom.ThrustRatio.Value; decPrec = custom.DecimalPrecision.Value; maxBank = custom.MaxBank.Value; pushback = custom.Pushback.Value; pushbackSpeed = math.abs(custom.Pushback.Speed.Value); canCrash = custom.CanCrash.Value; lockCam = custom.LockCamera.Value; bankSensitivity = (function() local s = custom.BankSensitivity.Value s = (s < 0 and 0 or s > 10 and 10 or s) s = ((10-s)/10) return (500+(2.5e3*s)) end)(); }
-- Throttle control: local throttle = { cur = 0; rate = 0.02; up = false; dn = false; bar = gui.Panel.Throttle.Bar; perc = gui.Panel.Throttle.Percent; update = function(self) if (self.dn or self.up) then if (self.up) then self.cur = (self.cur+self.rate) end if (self.dn) then self.cur = (self.cur-self.rate) end self.cur = (self.cur < 0 and 0 or self.cur > 1 and 1 or self.cur) self.bar.Size = UDim2.new(self.cur,0,1,0) self.perc.Text = (tostring(FLOOR(self.cur*100)) .. "%") if (self.cur > 0) then EndPushback() end end end; }
-- Like FindFirstChild, but it will create the object if it does not exist function FindOrCreate(parent,name,class,createFunc) local x = parent:FindFirstChild(name) if (not x) then x = Instance.new(class,parent) x.Name = name if (createFunc) then createFunc(x) end end return x end
ToggleLandingGear,IsLandingGearDown = (function() local lg = op.landingGear local f = properties.fadeLandingGear local down = true local active = false local all = {} local function Scan(p) for _,o in pairs(p:GetChildren()) do if (o:IsA("BasePart")) then table.insert(all,o) end Scan(o) end end Scan(lg) local function Fade(start,stop,step) for i = start,stop,step do for _,v in pairs(all) do v.Transparency = i end wait(1/30) end end return function() if (active) then return end Delay(0,function() active = true down = (not down) if (down) then if (f) then Fade(1,0,-0.2) end for _,v in pairs(all) do v.CanCollide = true v.Transparency = 0 end else EndPushback() if (f) then Fade(0,1,0.2) end for _,v in pairs(all) do v.CanCollide = false v.Transparency = 1 end end active = false end) end, function() return down end end)();
TogglePushback,EndPushback = (function() local pushing = false return function() if (pushing) then pushing = false elseif (throttle.cur <= 0 and op.main.Velocity.magnitude <= 6 and IsLandingGearDown()) then pushing = true end doPushback = pushing end, function() pushing,doPushback = false,false end end)();
function MouseDown() -- Left click down end
function MouseUp() -- Left click up end
function KeyDown(k) if (k == "w" or k:byte() == 17) then throttle.up = (true and not dead) elseif (k == "s" or k:byte() == 18) then throttle.dn = (true and not dead) elseif (k == "g" and not properties.autoLandingGear and not dead) then ToggleLandingGear() elseif (k == "b" and properties.pushback and not dead) then TogglePushback() end end
function KeyUp(k) if (k == "w" or k:byte() == 17) then throttle.up = false elseif (k == "s" or k:byte() == 18) then throttle.dn = false end end
-- Triggered when Health hits 0 (only if Customize.CanCrash is 'true') function Died() if (dead) then return end dead = true throttle.up,throttle.dn = false,false gui.Panel.Throttle.Bar.Size = UDim2.new(0,0,1,0) gui.Panel.Throttle.Percent.Text = "0%" EndPushback() end
-- Update the GUI InterfaceUpdate = (function() local panel = gui.Panel local alt = panel.Altitude.Amount local spd = panel.Speed.Amount local vspd = panel.VerticalSpeed.Amount local last = 0 local dec = properties.decPrec dec = (dec < 0 and 0 or dec > 3 and 3 or dec) local formatter = ("%." .. tostring(dec) .. "f") return function() local t = time() if ((t-last) < 0.1) then return end last = t alt.Text = formatter:format(op.main.Position.y) spd.Text = formatter:format(op.main.Velocity.magnitude) vspd.Text = formatter:format(op.main.Velocity.y) end end)();
-- Get the bank of the aircraft based on the user's mouse position on-screen (ratio relative to center-screen) function GetBank() local vsx,x = mouse.ViewSizeX,mouse.X -- ViewSizeX, X local vsxH = (vsx/2.0) -- ViewSizeX Half local r = ((vsxH-x)/vsxH) r = (r < -1 and -1 or r > 1 and 1 or r) -- Ratio local s = op.main.Velocity.magnitude -- Speed if (s < 45) then local sr = ((s-30)/45.0) -- Speed ratio sr = (sr < 0 and 0 or sr) r = (r*sr) gyro.maxTorque = V3NEW(maxThrust*sr,maxThrust,maxThrust*sr) else gyro.maxTorque = V3NEW(maxThrust,maxThrust,maxThrust) end return RAD(r*properties.maxBank) end
-- Calculate what the speed of the aircraft should actually be (inputted into BodyVelocity object of the plane) CalcDesiredSpeed = (function() local r = properties.spdIncRate; return function() local s,ds = (properties.maxSpeed*throttle.cur),properties.desiredSpeed ds = (s > ds and (ds+r) or s < ds and (ds-r) or ds) properties.desiredSpeed = ds end end)();
-- Update main flight controls (thrusting, direction, and speed calculations) function FlyUpdate() CalcDesiredSpeed() local r = (properties.desiredSpeed/properties.maxSpeed) local f = (maxThrust*r) thruster.maxForce = V3NEW(f,f*(op.main.Velocity.magnitude/properties.maxSpeed),f) thruster.velocity = (op.main.CFrame.lookVector*properties.desiredSpeed) if (not dead) then if (op.main.Velocity.magnitude > 2) then gyro.cframe = CFNEW(op.main.CFrame.p,mouse.Hit.p)*CFANG(0,0,GetBank()) end if (doPushback) then thruster.maxForce = V3NEW(properties.mass*100,0,properties.mass*100) thruster.velocity = (op.main.CFrame.lookVector*-properties.pushbackSpeed) end end end
-- Check to see if the plane is near the ground function NearGround() local ray = Ray.new(op.main.Position,V3NEW(0,-50,0)) local hit,pos = game.Workspace:FindPartOnRay(ray,player.Character,true) return (hit and true or false) end
-- Main update loop of the plane (executes about every 0.03 seconds) Update = (function() local autoLg = properties.autoLandingGear local lastAuto = 0 return function() FlyUpdate() InterfaceUpdate() throttle:update() if (autoLg) then local t = time() if ((t-lastAuto) > 0.5) then lastAuto = t local down = IsLandingGearDown() local near = NearGround() if ((near and not down) or (not near and down)) then ToggleLandingGear() end end end end end)();
-- First function called. This is basically the "start up" of the plane function Setup()
-- Hardware control event setup: mouse.Button1Down:connect(MouseDown) mouse.Button1Up:connect(MouseUp) mouse.KeyDown:connect(KeyDown) mouse.KeyUp:connect(KeyUp)
cam.CameraType = Enum.CameraType[(properties.lockCam and "Attach" or "Follow")]
gui.Panel.PlaneName.Text = properties.planeName gui.Panel.Visible = false gui.Parent = player.PlayerGui
-- Find or create movement objects: GetPlaneMass() GetMaxThrust() thruster = FindOrCreate(op.main,"Thruster","BodyVelocity") thruster.maxForce = V3NEW() thruster.velocity = V3NEW() gyro = FindOrCreate(op.main,"Gyro","BodyGyro",function(o) o.cframe = CFNEW(op.main.Position,(op.main.Position+op.main.CFrame.lookVector)) o.D = properties.bankSensitivity wait(1) o.maxTorque = V3NEW(maxThrust,maxThrust,maxThrust) end)
-- Health setup: local hBar,hTitle = gui.Panel.Health.Bar,gui.Panel.HealthTitle hTitle.Visible,gui.Panel.Health.Visible = properties.canCrash,properties.canCrash if (properties.canCrash) then local p = gui.Panel.Health.Percent hBar.Size = UDim2.new((health.Value/maxHealth),0,1,0) p.Text = (tostring(FLOOR((health.Value/maxHealth)*100)) .. "%") gui.Panel.Size = UDim2.new(0,200,0,130) health.Changed:connect(function(h) if (h < 0) then h = 0 end local r = (h/maxHealth) hBar.Size = UDim2.new(r,0,1,0) p.Text = (tostring(FLOOR(r*100)) .. "%") if (h == 0 and not dead) then Died() end end) end
gui.Panel.Visible = true
-- Core flight loop local w = (1/30) while (op.flying and not dead) do Update() wait(w) end throttle.cur = 0 while (op.flying and health.Value > -50) do Update() gyro.cframe = (gyro.cframe*CFANG(0,0,RAD(4))) wait(w) end op.flyingStopped = true
end
-- Get the mass of the plane function GetPlaneMass() if (properties.mass) then return properties.mass end local m = 0 local function Scan(p) for _,o in pairs(p:GetChildren()) do if (o:IsA("BasePart")) then m = (m+o:GetMass()) end Scan(o) end end Scan(plane) properties.mass = m return m end
-- Set the max thrust (function name 'Get' a bit misleading) function GetMaxThrust() maxThrust = ((properties.mass*(236/1.2))*properties.thrustRatio) end
-- Called when the user exits the plane function ForceRemove() op.flying = false gui:Destroy() cam.CameraType = Enum.CameraType.Custom while (not op.flyingStopped) do wait() end if (gyro and gyro.Parent) then gyro:Destroy() end if (thruster and thruster.Parent) then thruster:Destroy() end script.ForceRemove.Ready.Value = true end
local fr = script.ForceRemove if (fr.Value) then ForceRemove() else local con con = fr.Changed:connect(function(v) if (v) then con:disconnect() ForceRemove() end end) end Setup()
function wingani() local mouse = player:GetMouse()
function CalculateOffset() local offset = {} offset.X = mouse.X - mouse.ViewSizeX/2 offset.Y = mouse.Y - mouse.ViewSizeY/2 end
while true do wait() local offset = CalculateOffset()
end
CalculateOffset() end |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 12:46 AM |
@Pihs Stop acting like you are superior over Bam. Looking at your posts you are most likely new to scripter as well as Bam. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 12:51 AM |
Focus guys i really need the help i've been working on this all day this is the last part
function wingani() local mouse = player:GetMouse()
function CalculateOffset() local offset = {} offset.X = mouse.X - mouse.ViewSizeX/2 offset.Y = mouse.Y - mouse.ViewSizeY/2 end
while true do wait() local offset = CalculateOffset() ---Here is where i need help writing the code for example: X value moves right and left wings and Y moves tail elevators end
CalculateOffset()
end |
|
|
| Report Abuse |
|
|
Pihs
|
  |
| Joined: 26 Dec 2014 |
| Total Posts: 813 |
|
|
| 30 Dec 2014 12:59 AM |
@joel idiot
Read: "Banned12/26/2014 - + 55k Post Count
gtfo kid
Xucs/Leveraged/Tixmaker101/Cuxe - Banned 12/26/2014 - + 55k Post Count |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 01:01 AM |
| Paying 300 Robux to anyone who can help me finish the last part of the script |
|
|
| Report Abuse |
|
|
| |
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 30 Dec 2014 01:19 AM |
@Pihs He said your posts, not your post count. I'd agree, you still make the simplest mistakes.
@OP For the ailerons and elevators, how are they being adjusted? |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 02:00 AM |
| Don't listen to Pihs, he never knows what he's saying |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 09:00 AM |
@iiessence The aileron and elevators are being adjusted based on For example how far the mouse goes to the left or right Same for the elevators except the movement is up or down. So the movements are determined by the offsets. And (0,0) is the center of the screen.
If anyone else has info you are welcomed to comment below, thanks |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2014 09:00 AM |
^ Don't listen to him. He scams 12 year olds. |
|
|
| Report Abuse |
|
|