Data Realms Fan Forums http://45.55.195.193/ |
|
[Request] Two Scripts (probably not very complicated) http://45.55.195.193/viewtopic.php?f=73&t=35951 |
Page 1 of 1 |
Author: | MrC121989 [ Sun Dec 09, 2012 7:31 pm ] |
Post subject: | [Request] Two Scripts (probably not very complicated) |
Can someone please write me two scripts The first one i need is to make a missile fly in random dirrection (in mid air it will curve in different directions) And the second one i need is a script for a weapon where i can specify which actor can hold it, if he can't then the weapon is instantly dropped from his inventory. |
Author: | Asklar [ Sun Dec 09, 2012 10:42 pm ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
The first one you can do it using .ini. Just give spread to the particles that pushes the emitter (rocket). The second one isn't hard, but I haven't got any reliable methods for checking the parent, so this might simply result laggy: Code: function Create(self) self.ActorThatCanHoldThisWeapon = "Name of the Actor that can hold the weapon" self.parent = MovableMan:GetMOFromID(self.RootID) end function Update(self) if self.parent == nil or self.parent.ClassName ~= "AHuman" then self.parent = MovableMan:GetMOFromID(self.RootID) end if self.parent.PresetName ~= MovableMan:GetMOFromID(self.RootID).PresetName or self.parent.ClassName ~= "AHuman" then self.parent = MovableMan:GetMOFromID(self.RootID) end if self.parent.PresetName ~= self.ActorThatCanHoldThisWeapon then self.parent:SetState(Controller.WEAPON_DROP,true) end end It probably won't work, my CC lua is pretty rusty. |
Author: | MrC121989 [ Sun Dec 09, 2012 11:40 pm ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
1) Not what i was aiming to get, but it will do for now, maybe with some tweaking i can get it just right. 2) Just like you said, the script does not work |
Author: | Bad Boy [ Mon Dec 10, 2012 3:43 am ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
Try changing the 3rd last line to self.parent:GetController():SetState(Controller.WEAPON_DROP,true); Everything else seems okay on a cursory glance, though it could probably be streamlined a bit to use 2 if statements instead of 3. |
Author: | MrC121989 [ Mon Dec 10, 2012 12:50 pm ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
In both cases this line seems causing some errors. |
Author: | Asklar [ Mon Dec 10, 2012 9:33 pm ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
What does it print? |
Author: | CaveCricket48 [ Sat Feb 23, 2013 4:47 am ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
Change Code: self.parent:GetController():SetState(Controller.WEAPON_DROP,true); to Code: ToActor(self.parent):GetController():SetState(Controller.WEAPON_DROP,true); |
Author: | MrC121989 [ Sat Feb 23, 2013 5:05 am ] | ||
Post subject: | Re: [Request] Two Scripts (probably not very complicated) | ||
It worked, but it floods the console with this mesage now, i'm afraid if i will place multiple weapons on a map it will produce massive lag. BTW i was wondering how to make this weapon availiable to multiple units do i just write "self.ActorThatCanHoldThisWeapon = "Unit1"; "Unit2"; "Unit3"" ? And making a message popup when units that cant use it tries to pick it up, something like "Wrong unit class".
|
Author: | CaveCricket48 [ Sun Feb 24, 2013 6:10 am ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
Code: function Create(self) self.permittedUsers = {}; self.permittedUsers[1] = "Dummy"; self.permittedUsers[2] = "Browncoat Light"; self.permittedUsers[3] = "Crab"; -- You get the idea end function Update(self) if self.RootID ~= self.ID then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then local isPermitted = false; for i = 1, #self.permittedUsers do if actor.PresetName == self.permittedUsers[i] then isPermitted = true; break; end end if not isPermitted then ToActor(actor):GetController():SetState(Controller.WEAPON_DROP,true); if ToActor(actor):IsPlayerControlled() then local parentPlayer = ToActor(actor):GetController().Player; FrameMan:ClearScreenText(parentPlayer); FrameMan:SetScreenText("YOU ARE NOT PERMITTED TO USE THIS ITEM!",parentPlayer,0,2,true); end end end end end |
Author: | MrC121989 [ Sun Feb 24, 2013 10:49 am ] |
Post subject: | Re: [Request] Two Scripts (probably not very complicated) |
Awesome! Theres only slight problem, somehow the message desplays only once per match |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |