• Stools problems : VGui and Undo libs aren't working correctly
    3 replies, posted
Hello all, So i'm making a new Tool for GMod to help generating scripts for my Vehicle Controler (RRP Module : mod_vc2). I have two problems : - When i add a DPanelList to the tool display panel, it displays with extremely little size (you can't use any controls in it). - The library Undo won't work, so impossible to remove seats from the vehicle script. So the BuildCPanel function : [code] function TOOL.BuildCPanel(panel) panel:SetSpacing(10) panel:SetName("RealisticRoleplay VC2-Helper") local lst = vgui.Create("DPanelList", panel) lst:EnableHorizontal(false) lst:EnableVerticalScrollbar(true) lst:SetSpacing(10) local lbl = vgui.Create("DLabel") lbl:SetSize(256, 32) lbl:SetText("Choose seats Y-Offset") lst:AddItem(lbl) local numScr = vgui.Create("DNumberScratch") numScr:SetMin(0) numScr:SetValue(0) numScr:SetMax(10) numScr.OnValueChanged = function() net.Start("RRP_VC2Helper_OffsetChanged") net.WriteFloat(numScr:GetFloatValue()) net.SendToServer() end lst:AddItem(numScr) local lblChoosen = vgui.Create("DLabel") lblChoosen:SetSize(256, 32) lblChoosen:SetText("YOffset is -" .. numScr:GetFloatValue()) lst:AddItem(lblChoosen) end [/code] Now the undo code not working (it gets called but don't do anything) : [code] //This is part of the script generator, state represents what is the current placing thing (lights, seats, engine, car chest, ...) elseif (self.State == 10) then local vec = tr.HitPos vec:Add(Vector(0, 0, self.SeatYOffset)) local ent = ents.Create("prop_vehicle_prisoner_pod") ent:SetModel("models/nova/airboat_seat.mdl") ent:SetKeyValue("vehiclescript", "scripts/vehicles/prisoner_pod.txt") ent:SetPos(vec) ent:SetParent(entity) ent:Spawn() table.insert(self.VehicleSeats, entity:WorldToLocal(vec)) //Library block not working START undo.Create("vc2_helper_seat") undo.AddEntity(ent) undo.SetPlayer(self.Owner) undo.AddFunction(function(tab, arg2) table.removeValue(self.VehicleSeats, entity:WorldToLocal(vec)) end) undo.Finish() //Library block not working END end [/code] Thanks by advance, Yuri6037 [editline]18th January 2015[/editline] Ok so the first problem using VGui is solved ! But the second one (undo lib not working) is still there !!
Define "not working". Is self.Owner a valid entity? Is "ent" a valid entity?
By not working i say that it changes absolutely nothing, it's same as if the undo library had no C++/Lua code behind. self.Owner should be always a player (the player who hands the tool) ent is part of my system, and can't be null because it's a created Chair of source engine.
It is not supposed to "change" anything, it should add an undo to the by default Z key. It may fail if you assign an invalid player or entity object to it. print() out your ent and self.Owner variables. Does the function in the undo not doing anything? If that is the case, then get the return value from table.insert and use table.remove( table, the_number_from_table_insert )
Sorry, you need to Log In to post a reply to this thread.