|
| | #1 (permalink) |
| Newbie ![]() Join Date: Nov 2008
Posts: 9
![]() | Ok well I've been coding for all of 3 days.... well LUA any way. I am in the process of making an ION Cannon stool for wire mod. The Tool will make an ION Cannon and have inputs of what color the ion will be and when it activates you know all kinds of cool stuff. But I'm getting an error when i goto click on the STool in Gmod. It says it cant write to the Table, so i looked through my code to the point at code line 93 (where it said my error was) and i have an table.insert function there. Heres the code for the STool: Code: TOOL.Category = "Wire - Physics"
TOOL.Name = "IONCannon"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.ClientConVar[ "delay" ] = "1" --If automatic
TOOL.ClientConVar[ "sound" ] = "0"
TOOL.ClientConVar[ "damage" ] = "500"
TOOL.ClientConVar[ "automatic" ] = "0"
cleanup.Register( "wire_IONCannons" )
--Sounds
Sound( "ambient.electrical_zap_3" )
if ( CLIENT ) then
language.Add( "Tool_wire_IONCannon_name", "ION Cannon" )
language.Add( "Tool_wire_IONCannon_desc", "Makes things go BOOM!!!!!" )
language.Add( "Tool_wire_IONCannon_0", "Click somewhere to spawn a ION Cannon. Click on an existing ION Cannon to change it." )
language.Add( "Tool_wire_IONCannon_sound", "Shoot Sound" )
language.Add( "Undone_wire_IONCannon", "Undone ION Cannon" )
language.Add( "Cleanup_wire_IONCannon", "ION Cannon" )
language.Add( "Cleaned_wire_IONCannon", "Cleaned up all ION Cannons" )
language.Add( "SBoxLimit_wire_IONCannon", "You've reached the ION Cannon limit!" )
end
if (SERVER) then
CreateConVar('sbox_maxwire_IONCannons', 2)
end
function TOOL:LeftClick( trace, worldweld )
if ( trace.Entity && trace.Entity:IsPlayer() ) then return false end
if (CLIENT) then return true end
worldweld = worldweld or false
local ply = self:GetOwner()
local delay = self:GetClientNumber( "delay" )
local sound = self:GetClientInfo( "sound" )
local damage = self:GetClientNumber( "damage" )
-- Shoot Existing,
if ( trace.Entity:IsValid() && trace.Entity:GetClass() == "gmod_wire_IONCannon" && trace.Entity.pl == ply ) then
trace.Entity:SetDamage( damage )
trace.Entity:SetDelay( delay )
trace.Entity:SetSound( sound )
return true
end
if ( !self:GetSWEP():CheckLimit( "wire_IONCannon" ) ) then return false
end
if ( trace.Entity != NULL && (!trace.Entity:IsWorld() || worldweld) ) then
trace.HitPos = trace.HitPos + trace.HitNormal * 2
else
trace.HitPos = trace.HitPos + trace.HitNormal * 2
end
local IONCannon = MakeWireIONCannon( ply, trace.HitPos, nil, delay, damage, sound)
IONCannon:SetAngles( trace.HitNormal:Angle() )
local weld = WireLib.Weld(IONCannon, trace.Entity, trace.PhysicsBone, true, false, worldweld)
undo.Create("WireIONCannon")
undo.AddEntity( IONCannon )
undo.AddEntity( weld )
undo.SetPlayer( ply )
undo.Finish()
return true
end
function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "Header", {TEXT = "ION Cannon", Description = "#Tool_wire_IONCannon_desc"} )
local params = { Label = "#Presets", MenuButton = 1, Folder = "wire_IONCannon", Options = {}, CVars = {} }
params.Options.default = {
wire_IONCannon_delay = 1,
wire_IONCannon_damage = 500,
wire_IONCannon_sound = "Zap",
wire_IONCannon_ions = 1,
}
->>> HERE is problem table.insert{ params.CVars, "wire_IONCannon_delay" }
table.insert{ params.CVars, "wire_IONCannon_damage" }
table.insert{ params.CVars, "wire_IONCannon_sound" }
CPanel:AddControl{ "ComboBox", params }
--ION Cannon Sound
local IONSounds = { Label = "#Tool_wire_IONCannon_sound", MenuButton = 0, Options{}, CVars{}}
IONSounds["options"]["#No Sound"] = { wire_IONCannon_sound = "" }
IONSounds["options"]["#Zap1"] = { wire_IONCannon_sound = "ambient.electrical_zap_3"}
IONSounds["Options"]["#Zap2"] = { wire_IONCannon_sound = "ambient.electrical_zap_2"}
IONSounds["Options"]["#Zap3"] = { wire_IONCannon_sound = "ambient.electrical_zap_1"}
CPanel:Addcontrol{"ComboBox", IONSounds}
if ( SinglePlayer ()) then
CPanel:AddControl{ "Slider", { Label = "#Number of IONs",
Type = "Integer",
Min = 1,
Max = 3,
Command = "wire_IONCannon_ions" } }
end
--Delay Between The IONs
if ( SinglePlayer()) then
CPanel:AddControl{ "Slider", { Label = "#Delay",
Type = "Float",
Min = 1,
Max = 20,
Command = "wire_IONCannon_delay" } }
--Damage Of Each ION
CPanel:AddControl{ "Slider", { Label = "#Damage",
Type = "Integer",
Min = 500,
Max = 100000,
Command = "wire_IONCannon_delay" } }
else
CPanel:AddControl{ "Slider", { Label = "#Delay",
Type = "Float",
Min = 1,
Max = 25,
Command = "wire_IONCannon_delay" } }
--Damage Of Each ION
CPanel:AddControl{ "Slider", { Label = "#Damage",
Type = "Integer",
Min = 500,
Max = 10000,
Command = "wire_IONCannon_delay" } }
end
end
|
| | |
| Sponsored Links | |
| | #2 (permalink) |
| COMPLETE BLOODY BASTARD ![]() ![]() | Have you tried just doing: Code: params.CVars = { "wire_IONCannon_delay", "wire_IONCannon_damage", "wire_IONCannon_sound" }
__________________ “A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.” —Antoine De Saint-Exupery |
| | |
| | #3 (permalink) |
| Advanced Member ![]() | You could make better sounds... Believe me the zap sounds are bad.
__________________ Steps to take before asking about a broken wiremod or tools. ![]() Don't Read This! If you did you lose... |
| | |
| | #4 (permalink) | ||
| Newbie ![]() Join Date: Nov 2008
Posts: 9
![]() | Quote:
Quote:
| ||
| | |
| | #5 (permalink) | |
| Newbie ![]() Join Date: Nov 2008
Posts: 9
![]() | Quote:
Code: function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "Header", {TEXT = "ION Cannon", Description = "#Tool_wire_IONCannon_desc"} )
local params = { Label = "#Presets", MenuButton = 1, Folder = "wire_IONCannon", Options = {}, CVars = {} }
params.CVars = { "wire_IONCannon_delay""wire_IONCannon_damage","wire_IONCannon_sound", "wire_IONCannon_ions"}
CPanel:AddControl{ "ComboBox", params }
--ION Cannon Sound
local IONSounds = { Label = "#Tool_wire_IONCannon_sound", MenuButton = 0, Options{}, CVars{}}
IONSounds["options"]["#No Sound"] = { wire_IONCannon_sound = "" }
IONSounds["options"]["#Zap1"] = { wire_IONCannon_sound = "ambient.electrical_zap_3"}
IONSounds["Options"]["#Zap2"] = { wire_IONCannon_sound = "ambient.electrical_zap_2"}
IONSounds["Options"]["#Zap3"] = { wire_IONCannon_sound = "ambient.electrical_zap_1"}
CPanel:Addcontrol{"ComboBox", IONSounds}
EDIT: Wait..... after posting it i see the problem 1 sec let me see if it will work if i correct it. EDIT2: Man i must suck at LUA or something. I got another error where it's looking for a table. UGGGG. Error: sandbox\gamemode\spawnmenu\controlpanel.lua:99: ControlPanelBuildFunction Error: includes/extensions/table.lua:402: bad argument #1 to 'pairs' (table expected, got nil) I'm looking through the code now. EDIT3: So there arent any calls to a table in my whole thing, and i dont have 402 lines so im guessing some terribly wrong happened? Last edited by NEDM_Insane; 11-14-2008 at 06:37 PM.. | |
| | |
| | #6 (permalink) |
| Newbie ![]() Join Date: Sep 2008
Posts: 2
![]() | Shouldn't the bad lines be: Code: table.insert( params.CVars, "wire_IONCannon_delay" ) table.insert( params.CVars, "wire_IONCannon_damage" ) table.insert( params.CVars, "wire_IONCannon_sound" ) Your use of braces {} instead of parentheses () in the CPanel Method might also be your other problem. Last edited by SERPENT711; 11-14-2008 at 08:54 PM.. |
| | |
| | #7 (permalink) | |
| Newbie ![]() Join Date: Nov 2008
Posts: 9
![]() | Quote:
| |
| | |
| | #8 (permalink) |
| Newbie ![]() Join Date: Nov 2008
Posts: 9
![]() | ok with the tables in the code i am getting this error: Code: sandbox\gamemode\spawnmenu\controlpanel.lua:99: ControlPanelBuildFunction Error: weapons\gmod_tool\stools/wire_IONCannon.lua:95: wrong number of arguments to 'insert' table:insert{ table,value } So why is it not working? Last edited by NEDM_Insane; 11-16-2008 at 09:11 AM.. |
| | |
| | #9 (permalink) |
| Newbie ![]() Join Date: Sep 2008
Posts: 2
![]() | It isn't working because by using {table, value} you are making a table with "table" and "value" as its members and passing that 1 table to the insert method. Try using: Code: table:insert( table,value ) |
| | |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|