<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title><![CDATA[Wiremod.com Forums - Developer's Showcase]]></title>
		<link>http://www.wiremod.com/forum/</link>
		<description>Take alook at some of the upcoming work from the wiremod team.</description>
		<language>en</language>
		<lastBuildDate>Wed, 08 Sep 2010 16:14:16 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.wiremod.com/forum/images/vblue/misc/rss.png</url>
			<title><![CDATA[Wiremod.com Forums - Developer's Showcase]]></title>
			<link>http://www.wiremod.com/forum/</link>
		</image>
		<item>
			<title><![CDATA[[E2] i/o functions]]></title>
			<link>http://www.wiremod.com/forum/developers-showcase/22402-e2-i-o-functions.html</link>
			<pubDate>Sun, 05 Sep 2010 13:59:55 GMT</pubDate>
			<description><![CDATA[I've created a few I/O functions (aka Input/Output) for E2. You can modify the E2's outputs using a string and get an array of all entities wired to...]]></description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->I've created a few I/O functions (aka Input/Output) for E2. You can modify the E2's outputs using a string and get an array of all entities wired to your E2's output.<br />
<br />
Example usage (showing the SetOutput function) in a simple 8-barreled gun, making them fire one at a time. Simpler than typing out &quot;Gun1 = something, Gun2 = something&quot; eight times.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">@inputs Fire<br />
@outputs Gun1 Gun2 Gun3 Gun4 Gun5 Gun6 Gun7 Gun8<br />
@persist X<br />
if (Fire) {<br />
&nbsp; &nbsp; interval(100)<br />
&nbsp; &nbsp; X++<br />
&nbsp; &nbsp; if(X&gt;8) {X=1}<br />
&nbsp; &nbsp; ioSetOutput(&quot;Gun&quot;+((X==1 ? 9 : X)-1),0)<br />
&nbsp; &nbsp; ioSetOutput(&quot;Gun&quot;+X,1)<br />
}</code><hr />
</div> It's not done yet, and needs some type checking so that you don't try to set an entity to a number and such, but will soon be finished.<br />
I'm posting this here so you can suggest optimizations or fixes that I may have missed, and to comment on whether or not you'd like it in the official SVN or the UWSVN, or neither.<br />
<br />
Code:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">/******************************************************************************/<br />
-- i/o functions<br />
<br />
-- Returns an array of all entities wired to the output<br />
e2function array ioOutputEntities( string output )<br />
&nbsp; &nbsp; &nbsp; &nbsp; local ret = {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (self.entity.Outputs[output]) then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local tbl = self.entity.Outputs[output].Connected<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i=1,#tbl do if (ValidEntity(tbl[i].Entity)) then ret[#ret+1] = tbl[i].Entity end end<br />
&nbsp; &nbsp; &nbsp; &nbsp; end<br />
&nbsp; &nbsp; &nbsp; &nbsp; return ret<br />
end<br />
<br />
-- Returns the entity the input is wired to<br />
e2function entity ioInputEntity( string input )<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (self.entity.Inputs[input] and self.entity.Inputs[input].Src and ValidEntity(self.entity.Inputs[input].Src)) then return self.entity.Inputs[input].Src end<br />
end<br />
<br />
local function setOutput( self, args, Type )<br />
&nbsp; &nbsp; &nbsp; &nbsp; local op1, op2 = args[2], args[3]<br />
&nbsp; &nbsp; &nbsp; &nbsp; local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (self.entity.Outputs[rv1] and self.entity.Outputs[rv1].Type == Type) then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.vars[rv1] = rv2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.vclk[rv1] = true<br />
&nbsp; &nbsp; &nbsp; &nbsp; end<br />
end<br />
<br />
local function getInput( self, args, default, Type )<br />
&nbsp; &nbsp; &nbsp; &nbsp; local op1 = args[2]<br />
&nbsp; &nbsp; &nbsp; &nbsp; local rv1 = op1[1](self,op1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (type(default) == &quot;table&quot;) then default = table.Copy(default) end<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (self.entity.Inputs[rv1] and self.entity.Inputs[rv1].Type == Type) then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.vars[rv1] or default<br />
&nbsp; &nbsp; &nbsp; &nbsp; end<br />
&nbsp; &nbsp; &nbsp; &nbsp; return default<br />
end<br />
<br />
local excluded_types = {<br />
&nbsp; &nbsp; &nbsp; &nbsp; xgt = true,<br />
}<br />
<br />
local function upperfirst( word )<br />
&nbsp; &nbsp; &nbsp; &nbsp; return word:Left(1):upper() .. word:Right(-2):lower()<br />
end<br />
<br />
registerCallback(&quot;postinit&quot;,function()<br />
&nbsp; &nbsp; &nbsp; &nbsp; for k,v in pairs( wire_expression_types ) do<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!excluded_types[short]) then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local short = v[1]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; registerFunction(&quot;ioSetOutput&quot;,&quot;s&quot;..short,&quot;&quot;..short,function(self,args) return setOutput(self,args,k) end)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; registerFunction(&quot;ioGetInput&quot;..upperfirst(k == &quot;NORMAL&quot; and &quot;NUMBER&quot; or k),&quot;s&quot;,short,function(self,args) return getInput(self,args,v[2],k) end)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br />
&nbsp; &nbsp; &nbsp; &nbsp; end<br />
end)</code><hr />
</div> <!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.wiremod.com/forum/developers-showcase/"><![CDATA[Developer's Showcase]]></category>
			<dc:creator>Divran</dc:creator>
			<guid isPermaLink="true">http://www.wiremod.com/forum/developers-showcase/22402-e2-i-o-functions.html</guid>
		</item>
		<item>
			<title>Block comments/strings</title>
			<link>http://www.wiremod.com/forum/developers-showcase/22179-block-comments-strings.html</link>
			<pubDate>Sun, 22 Aug 2010 23:52:12 GMT</pubDate>
			<description>As Divran hinted (http://www.wiremod.com/forum/off-topic/10418-longest-thread-ever-1one-junk-thread-515.html#post208796) in the longest thread evar,...</description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->As Divran <a href="!m10418!http://www.wiremod.com/forum/off-topic/10418-longest-thread-ever-1one-junk-thread-515.html#post208796" target="_blank">hinted</a> in the longest thread evar, I am adding block comments/multiline strings to E2. Syntax is:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#[ Ooo, block comments<br />
The E2 can't see this text, bwahaha! ]#<br />
<br />
if (Stuff #[ &amp; BrokenStuff ]#)<br />
{<br />
&nbsp; &nbsp; moarStuff()<br />
}<br />
<br />
print(&quot;Hey look<br />
strings can go to the next line.<br />
BTW, newlines are preserved, so the text is printed in multiple lines.<br />
You can stop this by placing a backslash \<br />
at the end of the line.&quot;)</code><hr />
</div> I also added an escape to allow adding characters by their decimal equivalent, effectively running string.char on them.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Test = &quot;\d120&quot; # Test = &quot;x&quot;</code><hr />
</div> I'll be releasing them when I completely bug test them, and when Divran gives me his highlighting code.<br />
<br />
A few things to note:<br />
1. Preprocessor statements (#ifdef, ect.), will not be executed if inside a block comment.<br />
2. For the \d### and \h## syntax, numbers less than 32 or greater than 255 will be ignored, and the statement will be replaced with &quot;&quot;<br />
3. You can't do:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Test = &quot;\d&quot;+Number</code><hr />
</div> Use toChar.<br />
<br />
ToDo:<ul><li><s>Block comments break column numbers when errors occur.</s> Done!</li>
<li><s>Test \d### with wierd numbers.</s> Now has same restrictions as the toChar function</li>
<li><s>Bug Divran to give me the code to the highlighter.</s> Done!</li>
<li>Add \h## for adding characters based on hexadecimal representation.</li>
<li>Clean up code in the preprocessor (I effectively rewrote the whole process of removing comments.)</li>
<li>Commit.</li>
</ul><!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.wiremod.com/forum/developers-showcase/"><![CDATA[Developer's Showcase]]></category>
			<dc:creator>initrd.gz</dc:creator>
			<guid isPermaLink="true">http://www.wiremod.com/forum/developers-showcase/22179-block-comments-strings.html</guid>
		</item>
		<item>
			<title><![CDATA[[E2] Built-in ranger changes?]]></title>
			<link>http://www.wiremod.com/forum/developers-showcase/22052-e2-built-ranger-changes.html</link>
			<pubDate>Tue, 17 Aug 2010 12:27:20 GMT</pubDate>
			<description><![CDATA[I noticed there are a lot of more data you can get out of a ranger trace which isn't accessible through E2. 
 
I've already made these and they will...]]></description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->I noticed there are a lot of more data you can get out of a ranger trace which isn't accessible through E2.<br />
<br />
I've already made these and they will be committed:<ul><li>ranger:fraction()</li>
<li>ranger:hitSky()</li>
<li>ranger:hitWorld()</li>
<li>ranger:matType()</li>
<li>ranger:toTable()</li>
<li>ranger:hitGroup()</li>
</ul><br />
I'm going to make these:<ul><li>None atm. They have all been made :) See above</li>
</ul><br />
I'm thinking of making these:<ul><li>ranger:fractionLeftSolid()</li>
<li>ranger:positionLeftSolid()</li>
</ul><br />
And I'm having compatibility issues with these:<ul><li>ranger:position() and ranger:fractionLeftSolid()/ranger:leftSolidPosition()<br />
Currently, ranger:position() returns the position where it leaves the solid area if it was created inside a solid area. (By solid, I mean the world. Props don't count)<br />
This, however, makes fractionLeftSolid and leftSolidPosition pointless. Therefore, I'm considering changing ranger:position() so that it returns the hit position like Lua does (ie if the ranger starts in the world, and exits the solid brush, continues on, and hits another solid face, it should return THAT hit position. That's how the regular Lua traces work). I can then add the other two functions and they will then have a purpose.</li>
</ul><br />
<br />
The reason I'm posting this is for you to discuss and suggest what you think should be done about this/these compatibility issues (By compatibility issues I'm referring to the fact that old E2s may break). Also created a poll.<br />
<br />
EDIT: Also, here's the Gmod Wiki page which explains what all of these things do: <a href="http://wiki.garrysmod.com/?title=Traceres" target="_blank">http://wiki.garrysmod.com/?title=Traceres</a><br />
<br />
EDIT: <font color="red">REMEMBER</font> it will only be a compatibility problem for old E2s who need to scan the ground (for simple obstacle - gaps/chasms in this case - avoidance or similar), because it only affects traces which were started inside the world and exits it.<!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.wiremod.com/forum/developers-showcase/"><![CDATA[Developer's Showcase]]></category>
			<dc:creator>Divran</dc:creator>
			<guid isPermaLink="true">http://www.wiremod.com/forum/developers-showcase/22052-e2-built-ranger-changes.html</guid>
		</item>
		<item>
			<title><![CDATA[[E2] pointContents will be added soon. This is a tutorial thread.]]></title>
			<link>http://www.wiremod.com/forum/developers-showcase/22050-e2-pointcontents-will-added-soon-tutorial-thread.html</link>
			<pubDate>Tue, 17 Aug 2010 10:27:58 GMT</pubDate>
			<description>When I found the function *Util.PointContents Image: http://wiki.garrysmod.com/favicon.ico  (http://wiki.garrysmod.com/?title=Util.PointContents)* on...</description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->When I found the function <b><a href="http://wiki.garrysmod.com/?title=Util.PointContents" target="_blank">Util.PointContents <img src="http://wiki.garrysmod.com/favicon.ico" border="0" alt="" /></a></b> on the wiki, I thought it could be useful for E2. I was then reminded of its usefulness in an E2 ranger thread, so I (with help from emspike) made it. I just have to ask emspike if he has anything to change about them when he comes online, then I will commit the functions.<br />
<br />
Ok this is no longer tricky to use, but I'll explain anyway since I already made this thread:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">N = pointHasContent( V, S )</code><hr />
</div> Returns 1 if the point V has any of the contents specified in S.<br />
<br />
Available contents are the ones on the above wiki page, without the initial &quot;CONTENTS_&quot; bit. Lower or upper case does not matter. Example<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">print(pointHasContent( entity():pos() - vec(0,0,50), &quot;water&quot; ))</code><hr />
</div> Placing the E2 above water will print 1, anywhere else will print 0.<br />
<br />
Notice that you can specify several contents at once, seperated with a comma. The comma works like an &quot;or&quot; symbol, so the function returns 1 if any one of the strings given exist in the point.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">print(pointHasContent( entity():pos() - vec(0,0,50), &quot;water,solid&quot; ))</code><hr />
</div> Placing the E2 above water OR the solid world will print 1, anywhere else will print 0.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">S = pointContents( V )</code><hr />
</div> This returns a string with all contents on the point V.<!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.wiremod.com/forum/developers-showcase/"><![CDATA[Developer's Showcase]]></category>
			<dc:creator>Divran</dc:creator>
			<guid isPermaLink="true">http://www.wiremod.com/forum/developers-showcase/22050-e2-pointcontents-will-added-soon-tutorial-thread.html</guid>
		</item>
	</channel>
</rss>
