Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions entities/entities/nut_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if (SERVER) then
self:PhysicsInit(SOLID_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:setNetVar("id", itemTable.uniqueID)
self:setNetVar("instanceID", itemTable:getID())
self.nutItemID = itemID

if (table.Count(itemTable.data) > 0) then
Expand Down Expand Up @@ -192,11 +193,11 @@ else
end

function ENT:getItemID()
return self:getNetVar("id", "")
return self:getNetVar("instanceID", "")
end

function ENT:getItemTable()
return nut.item.list[self:getItemID()]
return nut.item.instances[self:getItemID()]
end

function ENT:getData(key, default)
Expand Down
4 changes: 2 additions & 2 deletions gamemode/core/derma/cl_inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ renderedIcons = renderedIcons or {}
-- To make making inventory variant, This must be followed up.
function renderNewIcon(panel, itemTable)
-- re-render icons
if ((itemTable.iconCam and !renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then
if ((itemTable.iconCam and not renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then
local iconCam = itemTable.iconCam
iconCam = {
cam_pos = iconCam.pos,
cam_ang = iconCam.ang,
cam_fov = iconCam.fov,
}
renderedIcons[string.lower(itemTable.model)] = true

panel.Icon:RebuildSpawnIconEx(
iconCam
)
Expand Down
16 changes: 8 additions & 8 deletions gamemode/core/libs/sh_character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ do
local allowExistNames = nut.config.get("allowExistNames", true)

-- Fetch existing character names
if (CLIENT and #nut.char.names < 1 and !allowExistNames) then
if (CLIENT and #nut.char.names < 1 and not allowExistNames) then
netstream.Start("nutCharFetchNames")

netstream.Hook("nutCharFetchNames", function(data)
Expand All @@ -114,7 +114,7 @@ do
end

-- Check whether the chosen character name already exists
if (!nut.config.get("allowExistNames", true)) then
if (not nut.config.get("allowExistNames", true)) then
for k, v in pairs(nut.char.names) do
if (v == value) then
return false, "A character with this name already exists."
Expand Down Expand Up @@ -161,7 +161,7 @@ do

local minLength = nut.config.get("minDescLen", 16)

if (!value or #value:gsub("%s", "") < minLength) then
if (not value or #value:gsub("%s", "") < minLength) then
return false, "descMinLen", minLength
end
end
Expand Down Expand Up @@ -244,7 +244,7 @@ do
local faction = nut.faction.indices[data.faction]

if (faction) then
if (!data.model or !faction.models[data.model]) then
if (not data.model or not faction.models[data.model]) then
return false, "needModel"
end
else
Expand Down Expand Up @@ -337,7 +337,7 @@ do

data[key] = value

if (!noReplication and IsValid(client)) then
if (not noReplication and IsValid(client)) then
netstream.Start(
receiver or client,
"charData",
Expand All @@ -352,7 +352,7 @@ do
local data = character.vars.data or {}

if (key) then
if (!data) then
if (not data) then
return default
end

Expand All @@ -374,7 +374,7 @@ do

data[key] = value

if (!noReplication and IsValid(client)) then
if (not noReplication and IsValid(client)) then
local id

if (
Expand All @@ -396,7 +396,7 @@ do
local data = character.vars.vars or {}

if (key) then
if (!data) then
if (not data) then
return default
end

Expand Down
51 changes: 33 additions & 18 deletions gamemode/core/libs/sh_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function nut.command.add(command, data)
-- Or if we specify a usergroup allowed to use this.
elseif (data.group) then
-- The group property can be a table of usergroups.
if (type(data.group) == "table") then
if istable(data.group) then
data.onCheckAccess = function(client)
-- Check if the client's group is allowed.
for k, v in ipairs(data.group) do
for _, v in ipairs(data.group) do
if (client:IsUserGroup(v)) then
return true
end
Expand All @@ -43,7 +43,7 @@ function nut.command.add(command, data)
else
data.onCheckAccess = function(client)
return client:IsUserGroup(data.group)
end
end
end
end
end
Expand All @@ -68,11 +68,11 @@ function nut.command.add(command, data)
local alias = data.alias

if (alias) then
if (type(alias) == "table") then
for k, v in ipairs(alias) do
if istable(alias) then
for _, v in ipairs(alias) do
nut.command.list[v:lower()] = data
end
elseif (type(alias) == "string") then
elseif isstring(alias) then
nut.command.list[alias:lower()] = data
end
end
Expand Down Expand Up @@ -144,22 +144,37 @@ end
if (SERVER) then
-- Finds a player or gives an error notification.
function nut.command.findPlayer(client, name)
local target = type(name) == "string" and nut.util.findPlayer(name) or NULL
if isstring(name) then
if name == "^" then -- thank you Hein/Hankshark - Tov
return client
elseif name == "@" then
local trace = client:GetEyeTrace().Entity
if IsValid(trace) and trace:IsPlayer() then
return trace
else
client:notifyLocalized("lookToUseAt")
return
end
end
local target = nut.util.findPlayer(name) or NULL

if (IsValid(target)) then
return target
if (IsValid(target)) then
return target
else
client:notifyLocalized("plyNoExist")
end
else
client:notifyLocalized("plyNoExist")
client:notifyLocalized("mustProvideString")
end
end

-- Finds a faction based on the uniqueID, and then the name if no such uniqueID exists.
function nut.command.findFaction(client, name)
if (nut.faction.teams[name]) then
return nut.faction.teams[name]
end

for k, v in ipairs(nut.faction.indices) do
for _, v in ipairs(nut.faction.indices) do
if (nut.util.stringMatches(L(v.name,client), name)) then
return v --This interrupt means we don't need an if statement below.
end
Expand All @@ -170,15 +185,15 @@ if (SERVER) then

-- Forces a player to run a command.
function nut.command.run(client, command, arguments)
local command = nut.command.list[command:lower()]
command = nut.command.list[command:lower()]

if (command) then
-- Run the command's callback and get the return.
local results = {command.onRun(client, arguments or {})}
local result = results[1]

-- If a string is returned, it is a notification.
if (type(result) == "string") then
if isstring(result) then
-- Normal player here.
if (IsValid(client)) then
if (result:sub(1, 1) == "@") then
Expand Down Expand Up @@ -210,8 +225,8 @@ if (SERVER) then

match = post[1]:utf8sub(2, len)
end
local match = match:lower()

match = match:lower()

local command = nut.command.list[match]
-- We have a valid, registered command.
Expand Down Expand Up @@ -252,8 +267,8 @@ if (SERVER) then
if ((client.nutNextCmd or 0) < CurTime()) then
local arguments2 = {}

for k, v in ipairs(arguments) do
if (type(v) == "string" or type(v) == "number") then
for _, v in ipairs(arguments) do
if (isstring(v) or isnumber(v)) then
arguments2[#arguments2 + 1] = tostring(v)
end
end
Expand Down
10 changes: 5 additions & 5 deletions gamemode/core/libs/sh_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function nut.item.load(path, baseID, isBaseItem)
if (uniqueID) then
uniqueID = (isBaseItem and "base_" or "")..uniqueID
nut.item.register(uniqueID, baseID, isBaseItem, path)
elseif (!path:find(".txt")) then
elseif (not path:find(".txt")) then
ErrorNoHalt(
"[NutScript] Item at '"..path.."' follows invalid "..
"naming convention!\n"
Expand Down Expand Up @@ -102,23 +102,23 @@ function nut.item.loadFromDir(directory)

files = file.Find(directory.."/base/*.lua", "LUA")

for k, v in ipairs(files) do
for _, v in ipairs(files) do
nut.item.load(directory.."/base/"..v, nil, true)
end

files, folders = file.Find(directory.."/*", "LUA")

for k, v in ipairs(folders) do
for _, v in ipairs(folders) do
if (v == "base") then
continue
end

for k2, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do
for _, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do
nut.item.load(directory.."/"..v .. "/".. v2, "base_"..v)
end
end

for k, v in ipairs(files) do
for _, v in ipairs(files) do
nut.item.load(directory.."/"..v)
end
end
Expand Down
4 changes: 2 additions & 2 deletions gamemode/core/libs/sv_database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ modules.tmysql4 = {
if (result) then
result = result[1]

local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data
local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data

if (queryStatus and queryStatus == true and callback) then
callback(data, lastID)
Expand Down Expand Up @@ -116,7 +116,7 @@ modules.tmysql4 = {
end
else
ThrowConnectionFault(fault)
end
end
end
}

Expand Down
Loading