• Is there a fix for this Ironsights Designer tool?
    13 replies, posted
[url]http://www.garrysmod.org/downloads/?a=view&id=29787[/url] Either I'm a complete n00b in Gmod 13 and does not know how to addons, or this doesn't work anymore. If there's no fix, can someone make one? I'd do it myself if I had the faintest idea what I'm doing. Currently I just can't get it to show up under the Weapons menu. A potentially idiotic question: How can I get this working again? Or are there any alternatives to it that aren't crap? Yes I've tried [url]http://steamcommunity.com/sharedfiles/filedetails/?id=109724869[/url] and it's crap. I can't fine-tune the adjustments of the iron sights like I do with this older tool.
Someone put this on the comments "I take that back. The Z coordinate does not work.. Add ~2 to it, and it seems ok..." So if you play around with the Z coordinate it might fix it
[QUOTE=djjkxbox360;38984384]Someone put this on the comments "I take that back. The Z coordinate does not work.. Add ~2 to it, and it seems ok..." So if you play around with the Z coordinate it might fix it[/QUOTE] No, it just doesn't show up in-game. I already saw this. It does not appear in Gmod 13's weapons, tools, entities, anywhere--so either I cannot addonz or it doesn't work. Did it work for you?
Did you change the info.txt?
[QUOTE=Spades_Neil;38987696]No, it just doesn't show up in-game. I already saw this. It does not appear in Gmod 13's weapons, tools, entities, anywhere--so either I cannot addonz or it doesn't work. Did it work for you?[/QUOTE] Rename info.txt to addon.txt and that should fix your problem. Unless the swep its-self is broken.
[QUOTE=Steven :D;38989005]Rename info.txt to addon.txt and that should fix your problem. Unless the swep its-self is broken.[/QUOTE] [ERROR] ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:203: invalid escape sequence near '"' 1. unknown - addons/ironsights_designer/lua/weapons/ironsights_designer/shared.lua:0 Well at least it's being detected now, but it's not showing up still.
[QUOTE=Spades_Neil;38992728][ERROR] ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:203: invalid escape sequence near '"' 1. unknown - addons/ironsights_designer/lua/weapons/ironsights_designer/shared.lua:0 Well at least it's being detected now, but it's not showing up still.[/QUOTE] Giving us the peice of code might help a bit :C
[QUOTE=Lerpaderp;39002785]Giving us the peice of code might help a bit :C[/QUOTE] Well, I did. It's in my first post. Seems more effective just giving you the addon than one line of code that may or may not solve all my problems. Plus it's been so long since I've screwed with any script that I'm not even sure where the error is pointing me. Line 203 perhaps? Here's 200 to 214 local org = {"x","y","z"} for k,line in pairs(lines) do local numStr = string.gsub (string.sub (line, string.find (line, "\(", 1, true)+1, string.find (line, "\)", 1, true)-1), " ", "") local tbl = string.Explode (",", numStr) if not #tbl == 3 then return end for k,v in pairs (tbl) do targetTbl[org[k]] = tonumber(v) end if targetTbl == self.IronsPos then targetTbl = self.IronsAng else success = true end end I tried damn it. :S
put the code in [lua][/lua] and space it out like it is in the code....
[QUOTE=CaptainFab;39010091]put the code in [lua][/lua] and space it out like it is in the code....[/QUOTE] Forgive me for making an arse of myself. I'm not exactly a frequent poster here. Let me try again... Lines 188 to 222 of shared.lua (if I am reading the error correctly, something is messed up here) [lua]function SWEP:MenuLoadIronsightFunctions () --Thank you RabidToaster with help approaching this/dealing with a string.find difficulty. local path = "ironsights/"..string.gsub(string.gsub(self.Weapon.Owner:GetViewModel():GetModel(), "models/weapons/", ""), ".mdl", "")..".txt" local success = false if file.Exists (path) then local str = file.Read (path) local lines = { string.sub (str, 1, string.find (str, "\n")-1), string.sub (str, string.find (str, "\n")+1) } local targetTbl = self.IronsPos local org = {"x","y","z"} for k,line in pairs(lines) do local numStr = string.gsub (string.sub (line, string.find (line, "\(", 1, true)+1, string.find (line, "\)", 1, true)-1), " ", "") local tbl = string.Explode (",", numStr) if not #tbl == 3 then return end for k,v in pairs (tbl) do targetTbl[org[k]] = tonumber(v) end if targetTbl == self.IronsPos then targetTbl = self.IronsAng else success = true end end end if success then self:SetMessage ("Ironsights loaded from "..path) else self:SetMessage ("Failed to load: "..path.." either invalid or does not exist.") end end[/lua] The whole script: [lua]local function VectorString (vec) return "Vector ("..math.floor (vec.x * 10000) / 10000 ..", "..math.floor (vec.y * 10000) / 10000 ..", "..math.floor (vec.z * 10000) / 10000 ..")" end if SERVER then AddCSLuaFile ("shared.lua") SWEP.HoldType = "ar2" else SWEP.Category = "Tools" SWEP.PrintName = "Ironsights Designer" SWEP.Author = "Devenger" SWEP.Contact = "devenger@gmail.com" SWEP.Purpose = "Design ironsight coordinates for scripted weapons" SWEP.Instructions = "Left click to drag weapon, right-click to change drag mode, press sprint to activate mouse and use menu.\nIronsight coordinates can be printed to console or saved to a .txt file." SWEP.Slot = 5 SWEP.SlotPos = 100 SWEP.ViewModelFlip = true end SWEP.Spawnable = false SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_pist_p228.mdl" SWEP.WorldModel = "models/weapons/w_pist_p228.mdl" SWEP.ViewModelFOV = 82 SWEP.BobScale = 0 SWEP.SwayScale = 0 SWEP.Primary.Ammo = "" SWEP.Secondary.Ammo = "" SWEP.IronsMul = 1 SWEP.IronsMulDir = 1 SWEP.IronsMoveTime = 0.25 SWEP.IronsPos = Vector (0,0,0) SWEP.IronsAng = Vector (0,0,0) SWEP.AnglesModes = { {{"IronsPos","x",0.5},{"IronsPos","z",0.5},"Position X/Z (Left/Right/Up/Down Positioning)", "Pos X/Z"}, {nil,{"IronsPos", "y",0.5},"Position Y (Backwards/Forwards)", "Pos Y"}, {{"IronsAng","y",-1},{"IronsAng","x",1},"Angles Pitch/Yaw (Left/Right/Up/Down Angling)", "Ang Pitch/Yaw"}, {{"IronsAng","z",-1},nil,"Angle Roll (Left/Right Lean)", "Ang Roll"} } SWEP.AnglesMode = 1 SWEP.Sensitivity = 0.0005 function SWEP:Initialize () self.IronsPos = Vector (0,0,0) self.IronsAng = Vector (0,0,0) end if SERVER then local function svSetViewModel (pl, cmd, args) local wpn = pl:GetActiveWeapon() local mName = string.gsub (args[1], ".mdl", "") if pl:GetActiveWeapon() and pl:GetActiveWeapon():GetClass() == "ironsights_designer" then --print ("got "..mName) if file.Exists ("../"..mName..".mdl") then --print ("new model: "..mName) util.PrecacheModel (mName..".mdl") wpn:GetTable().ViewModel = mName..".mdl" pl:SendLua ([[LocalPlayer():GetActiveWeapon():SetMessage ("Model changed to ]]..mName..[[.mdl")]]) pl:SendLua ([[LocalPlayer():GetActiveWeapon():GetTable().ViewModel = "]]..mName..[[.mdl"]]) pl:SendLua ([[LocalPlayer():GetViewModel():SetModel ("]]..mName..[[.mdl")]]) pl:SendLua ([[IDSTBKeys["Model"]:SetText ("- Model: ]]..mName..".mdl"..[[")]]) else pl:SendLua ([[LocalPlayer():GetActiveWeapon():SetMessage ("Could not find ]]..mName..[[.mdl")]]) end end end concommand.Add ("sv__IDSetViewModel", svSetViewModel) else function clSetViewModel (pl, cmd, args) local mName = string.gsub (args[1], ".mdl", "") if string.find (mName, "/") then LocalPlayer():ConCommand ("sv__IDSetViewModel "..mName) else LocalPlayer():ConCommand ("sv__IDSetViewModel models/weapons/"..mName) end end local wpnmodels = file.Find ("../models/weapons/*.mdl") for k,v in pairs (wpnmodels) do if string.sub (v, 1, 2) == "w_" then wpnmodels[k] = nil else wpnmodels[k] = string.gsub(string.lower(v), ".mdl", "") end end function clSetViewModelAC (cmd, args) if string.find (args, "/") then return {} end local args = string.sub (args, 2) local ACos = {} for k,v in pairs (wpnmodels) do local compN = string.gsub (v, ".mdl", "") if string.find (compN, args) then ACos[#ACos+1] = "ID_ViewModel "..string.gsub (v, ".mdl", "") end end return ACos end concommand.Add ("ID_ViewModel", clSetViewModel, clSetViewModelAC) end function SWEP:PrimaryAttack () end SWEP.LastSecondaryAttack = 0 function SWEP:SecondaryAttack () if SERVER then return end if self.LastSecondaryAttack > CurTime() - 0.1 then return end self.AnglesMode = self.AnglesMode + 1 if self.AnglesMode > #self.AnglesModes then self.AnglesMode = 1 end self.Dragging = false self.Owner:EmitSound ("Weapon_Pistol.Empty") self.LastSecondaryAttack = CurTime() end function SWEP:ToggleIronsights () if self.IronsToggleDown then return end self:MenuToggleIronsights () self.IronsToggleDown = true end function SWEP:ToggleMenu () if self.MenuToggleDown then return end self.MenuActive = not self.MenuActive gui.EnableScreenClicker (self.MenuActive) self.MenuToggleDown = true end function SWEP:MenuOpenModelEntry () if not IDModelTextEntry then local x = IDMenu.X + IDSTBKeys["Model"].X + 55 local y = IDMenu.Y + IDSTBKeys["Model"].Y - 1 IDModelTextEntry = vgui.Create ("ID_TextEntry") IDModelTextEntry:SetVisible (true) IDModelTextEntry:MakePopup() IDModelTextEntry:SetPos (x, y) IDModelTextEntry:SetSize (300, 21) IDModelTextEntry:SetText (string.gsub (IDSTBKeys["Model"]:GetValue(), "- Model: ", "")) IDModelButton = vgui.Create ("Button") IDModelButton:SetPos (x + 302, y) IDModelButton:SetText ("Set") IDModelButton:SetSize (40, 21) IDModelButton:GetTable().DoClick = function (self) LocalPlayer():ConCommand ("ID_ViewModel "..IDModelTextEntry:GetValue()) IDModelTextEntry:Remove() IDModelTextEntry = nil self:Remove() end else IDModelTextEntry:Remove() IDModelTextEntry = nil IDModelButton:Remove() end end function SWEP:MenuToggleIronsights () self.IronsMulDir = -self.IronsMulDir local str = "- Ironsights: Off" if self.IronsMulDir > 0 then str = "- Ironsights: On" end IDSTBKeys["Ironsights"]:SetText (str) end function SWEP:MenuToggleFlip () self.ViewModelFlip = not self.ViewModelFlip local str = "- Model flip: Off" if self.ViewModelFlip then str = "- Model flip: On" end IDSTBKeys["Flip"]:SetText (str) end function SWEP:MenuToggleCrosshair () self.DrawCrosshair = not self.DrawCrosshair local str = "- Crosshair: Off" if self.DrawCrosshair then str = "- Crosshair: On" end IDSTBKeys["Crosshair"]:SetText (str) end function SWEP:MenuPrintIronsightFunctions (miss) print ("--------------------\nSWEP.IronSightsPos = "..VectorString (self.IronsPos).."\nSWEP.IronSightsAng = "..VectorString (self.IronsAng).."\n--------------------\n") if not miss then self:SetMessage ("Functions printed to console") end end function SWEP:MenuLoadIronsightFunctions () --Thank you RabidToaster with help approaching this/dealing with a string.find difficulty. local path = "ironsights/"..string.gsub(string.gsub(self.Weapon.Owner:GetViewModel():GetModel(), "models/weapons/", ""), ".mdl", "")..".txt" local success = false
Its talking about the back slashes used in the code, see [Lua] string.find (line, "\(", 1, true)+1 [/lua] AND [Lua] string.find (line, "\)", 1, true)-1) [/Lua] The question know is how to fix it
[QUOTE=Nova Prospekt;44351909]Its talking about the back slashes used in the code, see [Lua] string.find (line, "\(", 1, true)+1 [/lua] AND [Lua] string.find (line, "\)", 1, true)-1) [/Lua] The question know is how to fix it[/QUOTE] Escape the slash: [Lua] string.find (line, "\\(", 1, true)+1 [/lua] AND [Lua] string.find (line, "\\)", 1, true)-1) [/Lua]
Good job on reviving 2 year old thread.
[QUOTE=Robotboy655;44352306]Good job on reviving 2 year old thread.[/QUOTE] Get off your high horse, I only replied to someone. And in your logic of rating people dump for continuing an 'already revived' thread, would you not agree that in replying yourself is hypocritical?
Sorry, you need to Log In to post a reply to this thread.