Skip to content

Commit

Permalink
Merge pull request #1342 from wiremod/master
Browse files Browse the repository at this point in the history
workshop branch update
  • Loading branch information
Divran authored Mar 7, 2017
2 parents 83ab802 + cd21b8d commit abc5809
Show file tree
Hide file tree
Showing 169 changed files with 5,564 additions and 714 deletions.
3,485 changes: 3,485 additions & 0 deletions .luacheckrc

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: python

before_install:
- pip install hererocks
- hererocks env --luajit 2.0.3 --luarocks latest
- source env/bin/activate

install:
- luarocks install luacheck

script:
- git diff --check $TRAVIS_COMMIT_RANGE
- git diff --name-only $TRAVIS_COMMIT_RANGE | grep '\.lua$' | xargs --no-run-if-empty luacheck --std min+garrysmod+wiremod
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Coding Guidelines

Please see https://github.com/wiremod/wire/wiki/Coding-style for information on how code formatting is standardized in the Wiremod project.

---

# Contributor Covenant Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

We do understand that participants who know one another may act in ways between them that could be considered unacceptable. It is our belief that this is not an issue so long as it is consentual. However, participants must still be concious, respectful, and considerate of third party observers, and as such we ask that participants keep unacceptable behavior minimal.

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4.

Modified by the WireTeam.
8 changes: 6 additions & 2 deletions addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title" : "Wiremod",
"type" : "tool",
"tags" : [ "build", "fun" ],
"description": "A collection of entities connectable by data wires, which allows for the creation of advanced contraptions.",
"description": "A collection of entities connectable by data wires utilizing logical concepts, which allows for the creation of advanced contraptions.",
"ignore" :
[
"*.psd",
Expand All @@ -12,11 +12,15 @@
"*.xcf",
".git*",
".gitignore",
".luacheckrc",
".travis.yml",
"CONTRIBUTING.md",
"generate-luacheck.sh",
"git-hooks-pre-commit",
"gitrid.sh",
"license",
"readme.md",
"wiremod.fgd",
"wiremod.jpg"
]
}
}
118 changes: 118 additions & 0 deletions generate-luacheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash

set -e

base_url='http://wiki.garrysmod.com'

detag() {
printf '%s' "${1##*>}"
}

wget -o /dev/null -O - "$base_url"/navbar/ |
sed -r '
# Split up before each closing tag
s#</#\n\0#g
' |
sed -r '
# Remove navbarlink tags
s/<a class='\''navbarlink'\'' .*>//g
# Remove everything before the last tag
s/.*</</
' |
{
section=
while read -r line; do
detagged="$(detag "$line")"

case "$line" in
'<h2'*' &raquo;')
# Parse menu headers
detagged="${detagged% &raquo;}"
case "$section" in
Hooks|Libraries|Classes|Panels)
printf ' "%s",\n' "$detagged"
;;

Structures|Shaders|'Lua Reference'|Global|Enumerations)
:
;;

*)
echo >&2 "unknown section '$section' for '$detagged'"
;;
esac
;;

'<a'*)
# Parse menu entries
case "$section" in
Global)
printf ' "%s",\n' "$detagged"
;;

Enumerations)
printf '\n --- %s\n' "$detagged"
echo >&2 "Retrieving enum data for $detagged"

url="$base_url/page/Enums/$detagged" # TODO: use URL from the <a> tag
wget "$url" -o /dev/null -O - |
sed -rn 's/^<td> ('"$detagged"'_[^[:space:]]+|[A-Z][A-Z0-9_]{2,})$/ "\1",/p'
;;

Structures|Shaders|'Lua Reference'|Hooks|Libraries|Classes|Panels)
:
;;

*)
echo >&2 "unknown section '$section' for '$detagged'"
;;
esac
;;

'<h1>'*)
section="$detagged"
case "$section" in
Reference)
:
;;

*)
echo >&2 "Parsing section $section"
printf '\n -- %s\n' "$section"
;;
esac
;;

'<h2>'*)
section="$detagged"
case "$section" in
Enumerations)
echo >&2 "Parsing section $section"
printf '\n -- %s' "$section" # No newline after this, to avoid double newlines
;;
esac
;;

'</'*|'<ul'*)
# Ignore closing tags and <ul> tags
:
;;

*)
echo >&2 "Warning: Unhandled line '$line'"
esac
done

printf '\n'
} |
sed -ri '
0,/BEGIN_GENERATED_CODE/ {
/BEGIN_GENERATED_CODE/ {
r /dev/stdin
}
b
}
/END_GENERATED_CODE/,$ b
d
' .luacheckrc
4 changes: 2 additions & 2 deletions lua/entities/base_wire_entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if CLIENT then
end

local function getWireName( ent )
local name = ent:GetNetworkedString("WireName")
local name = ent:GetNWString("WireName")
if not name or name == "" then return ent.PrintName else return name end
end

Expand Down Expand Up @@ -252,7 +252,7 @@ if CLIENT then

-- Basic legacy GetOverlayText, is no longer used here but we leave it here in case other addons rely on it.
function ENT:GetOverlayText()
local name = self:GetNetworkedString("WireName")
local name = self:GetNWString("WireName")
if name == "" then name = self.PrintName end
local header = "- " .. name .. " -"

Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gmod_wire_cd_ray.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function ENT:DoJob()
if (self.Command[0] ~= 0) then //write ray
disk.DiskMemory[sector_addr] = table.Copy(self.WriteBuffer)
else //read ray
self.WriteBuffer = disk.DiskMemory[sector_addr] or { [0] = 0 }
self.WriteBuffer = table.Copy(disk.DiskMemory[sector_addr]) or { [0] = 0 }
end
end
end
Expand Down
82 changes: 77 additions & 5 deletions lua/entities/gmod_wire_egp/lib/egplib/objectcontrol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,88 @@ end
----------------------------
-- Object order changing
----------------------------
function EGP:SetOrder( Ent, from, to )
if (!Ent.RenderTable or #Ent.RenderTable == 0) then return false end
if (Ent.RenderTable[from]) then
function EGP:SetOrder( Ent, from, to, dir )
if not Ent.RenderTable or #Ent.RenderTable == 0 then return false end
dir = dir or 0

if Ent.RenderTable[from] then
to = math.Clamp(math.Round(to or 1),1,#Ent.RenderTable)
table.insert( Ent.RenderTable, to, table.remove( Ent.RenderTable, from ) )
if (SERVER) then Ent.RenderTable[to].ChangeOrder = {from,to} end
if SERVER then Ent.RenderTable[from].ChangeOrder = {target=to,dir=dir} end
return true
end
return false
end

local already_reordered = {}
function EGP:PerformReorder_Ex( Ent, i )
local obj = Ent.RenderTable[i]
if obj then
-- Check if this object has already been reordered
if already_reordered[obj.index] then
-- if yes, get its new position (or old position if it didn't change)
return already_reordered[obj.index]
end

-- Set old position (to prevent recursive loops)
already_reordered[obj.index] = i

if obj.ChangeOrder then
local target = obj.ChangeOrder.target
local dir = obj.ChangeOrder.dir

local target_idx = 0
if dir == 0 then
-- target is absolute position
target_idx = target
else
-- target is relative position
local bool, k, v = self:HasObject( Ent, target )
if bool then
-- Check for order dependencies
k = self:PerformReorder_Ex( Ent, k ) or k

target_idx = k + dir
end
end

if target_idx ~= 0 then
-- Make a copy of the object and insert it at the new position
local copy = table.Copy(obj)
copy.ChangeOrder = nil
table.insert( Ent.RenderTable, target_idx, copy )

-- Update already reordered reference to new position
already_reordered[obj.index] = target_idx

return target_idx
else
return i
end
end
end
end

function EGP:PerformReorder( Ent )
-- Reset, just to be sure
already_reordered = {}

-- First pass, insert objects at their wanted position
for i=1,#Ent.RenderTable do
self:PerformReorder_Ex( Ent, i )
end

-- Second pass, remove objects from their original positions
for i=#Ent.RenderTable,1,-1 do
local obj = Ent.RenderTable[i]
if obj.ChangeOrder then
table.remove( Ent.RenderTable, i )
end
end

-- Clear some memory
already_reordered = {}
end

----------------------------
-- Create / edit objects
----------------------------
Expand Down
Loading

0 comments on commit abc5809

Please sign in to comment.