Skip to content

Commit abc5809

Browse files
authored
Merge pull request #1342 from wiremod/master
workshop branch update
2 parents 83ab802 + cd21b8d commit abc5809

File tree

169 files changed

+5564
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+5564
-714
lines changed

.luacheckrc

Lines changed: 3485 additions & 0 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: python
2+
3+
before_install:
4+
- pip install hererocks
5+
- hererocks env --luajit 2.0.3 --luarocks latest
6+
- source env/bin/activate
7+
8+
install:
9+
- luarocks install luacheck
10+
11+
script:
12+
- git diff --check $TRAVIS_COMMIT_RANGE
13+
- git diff --name-only $TRAVIS_COMMIT_RANGE | grep '\.lua$' | xargs --no-run-if-empty luacheck --std min+garrysmod+wiremod

CONTRIBUTING.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Coding Guidelines
2+
3+
Please see https://github.com/wiremod/wire/wiki/Coding-style for information on how code formatting is standardized in the Wiremod project.
4+
5+
---
6+
7+
# Contributor Covenant Code of Conduct
8+
9+
### Our Pledge
10+
11+
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.
12+
13+
### Our Standards
14+
15+
Examples of behavior that contributes to creating a positive environment include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
26+
- Trolling, insulting/derogatory comments, and personal or political attacks
27+
- Public or private harassment
28+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
29+
- Other conduct which could reasonably be considered inappropriate in a professional setting
30+
31+
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.
32+
33+
### Our Responsibilities
34+
35+
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.
36+
37+
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.
38+
39+
### Scope
40+
41+
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.
42+
43+
### Enforcement
44+
45+
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.
46+
47+
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.
48+
49+
### Attribution
50+
51+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4.
52+
53+
Modified by the WireTeam.

addon.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"title" : "Wiremod",
33
"type" : "tool",
44
"tags" : [ "build", "fun" ],
5-
"description": "A collection of entities connectable by data wires, which allows for the creation of advanced contraptions.",
5+
"description": "A collection of entities connectable by data wires utilizing logical concepts, which allows for the creation of advanced contraptions.",
66
"ignore" :
77
[
88
"*.psd",
@@ -12,11 +12,15 @@
1212
"*.xcf",
1313
".git*",
1414
".gitignore",
15+
".luacheckrc",
16+
".travis.yml",
17+
"CONTRIBUTING.md",
18+
"generate-luacheck.sh",
1519
"git-hooks-pre-commit",
1620
"gitrid.sh",
1721
"license",
1822
"readme.md",
1923
"wiremod.fgd",
2024
"wiremod.jpg"
2125
]
22-
}
26+
}

generate-luacheck.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
base_url='http://wiki.garrysmod.com'
6+
7+
detag() {
8+
printf '%s' "${1##*>}"
9+
}
10+
11+
wget -o /dev/null -O - "$base_url"/navbar/ |
12+
sed -r '
13+
# Split up before each closing tag
14+
s#</#\n\0#g
15+
' |
16+
sed -r '
17+
# Remove navbarlink tags
18+
s/<a class='\''navbarlink'\'' .*>//g
19+
20+
# Remove everything before the last tag
21+
s/.*</</
22+
' |
23+
{
24+
section=
25+
while read -r line; do
26+
detagged="$(detag "$line")"
27+
28+
case "$line" in
29+
'<h2'*' &raquo;')
30+
# Parse menu headers
31+
detagged="${detagged% &raquo;}"
32+
case "$section" in
33+
Hooks|Libraries|Classes|Panels)
34+
printf ' "%s",\n' "$detagged"
35+
;;
36+
37+
Structures|Shaders|'Lua Reference'|Global|Enumerations)
38+
:
39+
;;
40+
41+
*)
42+
echo >&2 "unknown section '$section' for '$detagged'"
43+
;;
44+
esac
45+
;;
46+
47+
'<a'*)
48+
# Parse menu entries
49+
case "$section" in
50+
Global)
51+
printf ' "%s",\n' "$detagged"
52+
;;
53+
54+
Enumerations)
55+
printf '\n --- %s\n' "$detagged"
56+
echo >&2 "Retrieving enum data for $detagged"
57+
58+
url="$base_url/page/Enums/$detagged" # TODO: use URL from the <a> tag
59+
wget "$url" -o /dev/null -O - |
60+
sed -rn 's/^<td> ('"$detagged"'_[^[:space:]]+|[A-Z][A-Z0-9_]{2,})$/ "\1",/p'
61+
;;
62+
63+
Structures|Shaders|'Lua Reference'|Hooks|Libraries|Classes|Panels)
64+
:
65+
;;
66+
67+
*)
68+
echo >&2 "unknown section '$section' for '$detagged'"
69+
;;
70+
esac
71+
;;
72+
73+
'<h1>'*)
74+
section="$detagged"
75+
case "$section" in
76+
Reference)
77+
:
78+
;;
79+
80+
*)
81+
echo >&2 "Parsing section $section"
82+
printf '\n -- %s\n' "$section"
83+
;;
84+
esac
85+
;;
86+
87+
'<h2>'*)
88+
section="$detagged"
89+
case "$section" in
90+
Enumerations)
91+
echo >&2 "Parsing section $section"
92+
printf '\n -- %s' "$section" # No newline after this, to avoid double newlines
93+
;;
94+
esac
95+
;;
96+
97+
'</'*|'<ul'*)
98+
# Ignore closing tags and <ul> tags
99+
:
100+
;;
101+
102+
*)
103+
echo >&2 "Warning: Unhandled line '$line'"
104+
esac
105+
done
106+
107+
printf '\n'
108+
} |
109+
sed -ri '
110+
0,/BEGIN_GENERATED_CODE/ {
111+
/BEGIN_GENERATED_CODE/ {
112+
r /dev/stdin
113+
}
114+
b
115+
}
116+
/END_GENERATED_CODE/,$ b
117+
d
118+
' .luacheckrc

lua/entities/base_wire_entity.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ if CLIENT then
103103
end
104104

105105
local function getWireName( ent )
106-
local name = ent:GetNetworkedString("WireName")
106+
local name = ent:GetNWString("WireName")
107107
if not name or name == "" then return ent.PrintName else return name end
108108
end
109109

@@ -252,7 +252,7 @@ if CLIENT then
252252

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

lua/entities/gmod_wire_cd_ray.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function ENT:DoJob()
132132
if (self.Command[0] ~= 0) then //write ray
133133
disk.DiskMemory[sector_addr] = table.Copy(self.WriteBuffer)
134134
else //read ray
135-
self.WriteBuffer = disk.DiskMemory[sector_addr] or { [0] = 0 }
135+
self.WriteBuffer = table.Copy(disk.DiskMemory[sector_addr]) or { [0] = 0 }
136136
end
137137
end
138138
end

lua/entities/gmod_wire_egp/lib/egplib/objectcontrol.lua

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,88 @@ end
100100
----------------------------
101101
-- Object order changing
102102
----------------------------
103-
function EGP:SetOrder( Ent, from, to )
104-
if (!Ent.RenderTable or #Ent.RenderTable == 0) then return false end
105-
if (Ent.RenderTable[from]) then
103+
function EGP:SetOrder( Ent, from, to, dir )
104+
if not Ent.RenderTable or #Ent.RenderTable == 0 then return false end
105+
dir = dir or 0
106+
107+
if Ent.RenderTable[from] then
106108
to = math.Clamp(math.Round(to or 1),1,#Ent.RenderTable)
107-
table.insert( Ent.RenderTable, to, table.remove( Ent.RenderTable, from ) )
108-
if (SERVER) then Ent.RenderTable[to].ChangeOrder = {from,to} end
109+
if SERVER then Ent.RenderTable[from].ChangeOrder = {target=to,dir=dir} end
109110
return true
110111
end
111112
return false
112113
end
114+
115+
local already_reordered = {}
116+
function EGP:PerformReorder_Ex( Ent, i )
117+
local obj = Ent.RenderTable[i]
118+
if obj then
119+
-- Check if this object has already been reordered
120+
if already_reordered[obj.index] then
121+
-- if yes, get its new position (or old position if it didn't change)
122+
return already_reordered[obj.index]
123+
end
124+
125+
-- Set old position (to prevent recursive loops)
126+
already_reordered[obj.index] = i
127+
128+
if obj.ChangeOrder then
129+
local target = obj.ChangeOrder.target
130+
local dir = obj.ChangeOrder.dir
131+
132+
local target_idx = 0
133+
if dir == 0 then
134+
-- target is absolute position
135+
target_idx = target
136+
else
137+
-- target is relative position
138+
local bool, k, v = self:HasObject( Ent, target )
139+
if bool then
140+
-- Check for order dependencies
141+
k = self:PerformReorder_Ex( Ent, k ) or k
142+
143+
target_idx = k + dir
144+
end
145+
end
146+
147+
if target_idx ~= 0 then
148+
-- Make a copy of the object and insert it at the new position
149+
local copy = table.Copy(obj)
150+
copy.ChangeOrder = nil
151+
table.insert( Ent.RenderTable, target_idx, copy )
152+
153+
-- Update already reordered reference to new position
154+
already_reordered[obj.index] = target_idx
155+
156+
return target_idx
157+
else
158+
return i
159+
end
160+
end
161+
end
162+
end
163+
164+
function EGP:PerformReorder( Ent )
165+
-- Reset, just to be sure
166+
already_reordered = {}
167+
168+
-- First pass, insert objects at their wanted position
169+
for i=1,#Ent.RenderTable do
170+
self:PerformReorder_Ex( Ent, i )
171+
end
172+
173+
-- Second pass, remove objects from their original positions
174+
for i=#Ent.RenderTable,1,-1 do
175+
local obj = Ent.RenderTable[i]
176+
if obj.ChangeOrder then
177+
table.remove( Ent.RenderTable, i )
178+
end
179+
end
180+
181+
-- Clear some memory
182+
already_reordered = {}
183+
end
184+
113185
----------------------------
114186
-- Create / edit objects
115187
----------------------------

0 commit comments

Comments
 (0)