+ Reply to Thread
Page 1 of 16 1 2 3 11 ... LastLast
Results 1 to 10 of 153

Thread: Jimlad's wire addons

  1. #1
    Wire Illusionist


    Jimlad will become famous soon enough Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    861

    Lightbulb Jimlad's Wire Addons

    This thread is no longer maintained, but I'll keep it around for reference

    This thread will be dedicated to the various fixes/addons I'll be making for wiremod. Just a place to consolidate them, get feedback, etc. - so they're easier to keep track of. This first post contains additions that haven't yet been committed, while the post below is an archive for those that either were or weren't accepted in the past.

    While a lot of mods feature entirely new stools or addon packages, the focus here is on bugfixes or additions to existing tools. My main motivation is just to make the small fixes necessary for me to make my contraptions more easily. I figured that rather than always bugging the devs to fix things, I might as well do it myself and maybe learn more about wiremod in the process.

    I'm totally open to feedback. In fact if you spot something I'm not doing quite right, please tell me. Don't be shy to point out corrections since I'm not a programmer, and I'd much rather learn from my mistakes than be ignorant of them!


    What to do next:

    (I'd actually prefer it if someone else did these since it'd probably get done faster, but tell me if you're working on it so I don't end up wasting my time!)


    Shorter term goals:
    • Update the wiki E2 examples page
    • Various patches/improvements for wire SENTs

    Longer term goals:
    • Add full quaternion support to E2
    • Look at updating the hoverdrive
    • Fiddle about with adv.duplicator - try to get buoyancy etc. to work?
    • Figure out why some wire entities don't retain nocollide after duplication
    Last edited by Jimlad; 08-25-2009 at 04:15 PM.

  2. #2
    Wire Illusionist


    Jimlad will become famous soon enough Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    861

    Default Re: Jimlad's wire addons

    This post is for all the addons that have already been committed to the svn, or simply aren't going to be added. It's mainly to help me keep track of the stuff I've done.

    (Additions are ordered by most recent first)


    E2 Basic Input Functions:
    Status: Added

    After receiving requests over the past months and thinking about adding input functions for some time, it's probably about time these were added. The functions will detect whether a player is pressing primary fire, secondary fire or use. These are probably the only input functions that will be added to the svn. For full input support see ZeikJT's input extension in the E2 unofficial addons.
    • keyAttack1(e:)
    • keyAttack2(e:)
    • keyUse(e:)

    Wire Damage Detector:
    Status: Added

    Made in response to requests for a way to detect damage in wire. Accepts an entity and array inputs so it can be used with entity markers and E2, and can be configured to detect damage on entities constrained to the input entity/entities.


    E2 4D vector/matrix functions:
    Status: Added

    Added two new variable types, vector4 and matrix4. These come with most of the features from 3D vectors/matrices, and changes have been made to the relevant 2D/3D functions as well to accommodate them. The additions also include a couple of changes to the 3D functions, including setDiagonal(m:v), mRotation(v,n) and an overhauled matrix(e) function, as well as a dehomogenized(v:) function that will convert 3D homogeneous vectors into 3D cartesian (standard) vectors.

    The matrix:up/forward/right functions have been replaced with matrix:x/y/z because to be honest, the old system didn't make much sense and didn't fit in with the coordinate system used by everything else.

    The array functions have also been updated to include the new vector and matrix variable types, and the debugger will now accept the vector4 type.


    Bounding Box functions for E2:
    Status: Added

    Exposing more lua functions, this time for finding the extents of an object's bounding box. This is probably the best method for finding an object's dimensions, and ideal if you're dealing with PHX plates. The original uses I had in mind were to allow you to build a hover car with rangers tracing from each corner of the car's chassis, and for manually detecting collisions with nocollided objects, but I'm sure there are all sorts of other applications.
    • boxCenter(e:)
    • boxMin(e:) / boxMax(e:)
    • boxSize(e:)

    Ranger array filter for E2:
    Status: Added

    Just a logical extension of ZeikJT's ranger filter function - can be combined with the findToArray() function pretty handily.


    Matrix Functions + 2D Vectors for E2:
    Status: Added

    This is a full suite of matrix functions for 2x2 and 3x3 matrices. No eigenvalue/vector stuff since it's not really justifiable right now, but there's room for more complex functions like that further down the line if it ends up being really necessary.

    2x2 & 3x3 Matrices
    • assign matrix values by numbers/vectors
    • zero matrix
    • identity matrix
    • convert between 2x2/3x3 matrices
    • delta
    • addition/subtraction
    • multiplication by a scalar
    • multiplication by a vector
    • multiplication by a matrix
    • division by a scalar
    • exponentiation (exponents have been limited to integers between -1 and 2)
    • set rows/columns by numbers or vectors
    • retrieve rows/columns as a vector
    • swap rows/columns
    • set individual elements by i,j
    • retrieve elements by i,j
    • swap elements
    • retrieve the leading diagonal as a vector
    • trace
    • determinant
    • transpose
    • adjugate

    3x3 Matrices only
    • Reference frame matrices for entities
    • Retrieve right/up/forward vectors from a reference frame matrix

    2D Vectors
    Also included is a full set of functions for 2D vectors to complement 2x2 matrices. These include all the standard functions present in the 3D vector library, along with the relevant alterations (e.g. for rotation, you need only give a single number value to represent the angle to rotate a 2D vector by). This comes with functions for converting between 2D and 3D matrices, and an update for displaying 2D vectors with the debugger.


    Interactable HoloEmitter "Vector" Patch & HoloEmitter "GroundBeams" Patch
    Status: Added

    This is a patch for the holoemitter to provide an option to turn off beams from the emitter itself. It seems a bit strange that such a basic feature is in wire extras but not in official wire, so I've shamelessly ripped the code from there.

    Also, I don't know whether anyone still maintains wire extras, but I've made a patch for the interactable holoemitter seeing as how the existing "Vector" input doesn't work and spams errors due to a typo.

    EDIT: Additionally, updating "groundbeams" didn't work on existing holoemitters, you had to create a new one to change the option. This has now been fixed.


    Adv. Pod Controller Entity output:
    Status: Added

    This simple patch adds an entity output to the Adv. Pod Controller, giving the pod entity, for use with E2. This is extremely useful, since gives you access to all the entity functions very easily, such as driver position with Entity:driver():pos(), and pod orientation with Entity:angles(). This also saves on having to use entity markers on every pod if they already have pod controllers attached.


    Additional Vector/Angle functions:
    Status: Added

    This is a suite of basic vector/angle maths functions for manipulating them more easily. The main goal is to save having to perform operations on each individual component, which is repetitive and unnecessary, and fills out E2 code like nobody's business. They basically fill out the vector/angle functions so they have the basic maths commands like for numbers.

    Vectors
    • ceil/floor
    • max/min
    • mod
    • clamp
    • mix
    • circular shift
    • vec(a) returning a vector
    Angles
    • ceil/floor
    • mod
    • clamp
    • mix
    • circular shift
    • ang(v) returning an angle


    inertia() function for E2:
    Status: Added

    Much like the e:mass() function for linear momentum, this is the equivalent for angular momentum. This is a much needed function for rotational control with objects of arbitrary dimensions and weights, eliminating all the guesswork you'd have to do otherwise! It seems that GMod doesn't bother giving you the products of inertia, it assumes all props are aligned with x,y,z along their principal axes. Basically this function will give you the principal moments of inertia, in the form (Ixx, Iyy, Izz). The upshot is that if you rotate a single prop about its centre of mass about its x, y, or z axes, it'll never wobble, which is pretty useful to know.


    isInWorld() function for E2:
    Status: Added

    Pretty simple function just to find out whether a position vector is in the world. Ought to be useful for hoverdrives, but I can think of a few other situations where it could come in handy.


    applyAngForce functions for E2:
    Status: Added

    Made as a "physics-enabled" fix for applyAngVel. Applies torque for the given angle, units in Force-inches.
    (Original credit to silentassassin12092, thanks to chinoto for testing)
    • applyAngForce(a)
    • applyAngForce(e:a)


    Mass functions for E2:
    Status: Added

    These are intended to work like the weight stool. They only work on player owned props, and are especially useful for the "applyForce()" command.
    • setMass(n)
    • setMass(e:n)


    Player aim functions for E2:
    Status: Added

    These work just like a combination of shootPos(), eye() and the ranger, but they're far more efficient and easier to use. Really useful, too.
    • aimEnt(e:)
    • aimPos(e:)

    The aimPos() function can be achieved in a similar fashion with the adv.pod controller, so it's not like it's adding anything revolutionary, it's just very helpful. Here's an example in E2 that turns whatever you're looking at green.

    Code:
    @name Greenify
    @persist LastEnt:entity StoreColor:vector
    
    interval(20)
    
    Entity = entity():owner():aimEntity()
    if (LastEnt != Entity) {
        LastEnt:setColor(StoreColor)
        StoreColor = Entity:getColor()
    }
    Entity:setColor(100,255,100)
    LastEnt = Entity
    
    Entity Marker fix & upgrade:
    Status: Added

    The code has been streamlined, with the "Think" function replaced by an event hook, used for checking when the marked entity is removed. The reload function giving client errors has now been fixed. I've also merged the lib code into wire_emarker.lua
    (Thanks ZeikJT)

    With the new functions for E2 coming out, I found the entity marker gets a lot more use than it did before. The old entity marker was broken and way out of date, so I fixed it up with proper duplicator support and a few upgrades so it's actually useable. This code has been tested on servers and I've been using it to build various things, and it seems to work pretty well so far.

    It now works a lot more intuitively - you left click to place them, and right click to link them, like all the other linkable tools. I added a new reload function so you can clear the links. Plus it'll give you feedback a lot like the adv. pod controller tool. Also, if you left click on a marker, it'll tell you the model of the entity it's linked to and show a line going to the linked entity, so no more searching around not having a clue what all your emarkers are actually doing.

    The emarker entity will now also detect if the prop it's linked to is removed, and update its overlay properly. This could get pretty confusing before!


    Colour functions for E2:
    Status: Added

    Added the colour functions library, with the following commands:
    • getColor(e:)
    • getAlpha(e:)
    • setColor(e:nnn) / (e:nnnn) / (e:v) / (e:vn)
    • setAlpha(e:n)

    EDIT: (02/06/09) Added setColor(e:v4)
    Last edited by Jimlad; 06-02-2009 at 11:31 AM.

  3. #3
    Newbie Programmer ZeikJT will become famous soon enough ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,394

    Default Re: Jimlad's wire addons

    Even though I've never used the entity marker myself, having it adv dupe correctly is definitely a good idea. If anyone can confirm it as working, or if it's been too many days I'll just commit it and hope for the best.

    As for the quaternions, I'll assume since you said full support you did see that there is already a laid out set of functions for them. I don't know if Syranide is still working on them or if it has been delayed.

    As for matricies, they would work a lot like tables inside of tables. So I don't really see the point. It would just be an easy way to loose track of data in most cases, of course in the right hands it would be useful.
    An easy way to fake matricies is to use good name systems (concatenation of strings) for the tables available:
    Code:
    @name
    @inputs Row:string Column:string Input Mode
    @outputs Read
    @persist T
    if(first()){T=table()}
    if(Mode==1){
    T:setNumber(Column+Row, Input)
    }
    if(Mode==2){
    Read=T:number(Column+Row)
    }
    
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  4. #4
    Wire Illusionist


    Jimlad will become famous soon enough Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    861

    Default Re: Jimlad's wire addons

    Yeah, the thing with the entity marker is it wasn't used much before, simply because you couldn't do a lot with it and it was a pain to use. It's increasingly becoming the case that you *can* do a lot with it, but that just makes it even more of a pain! Weirdly enough, one of the other devs tried patching it after I released my fix... yesterday, I think? But it was broken, although I think he released a fix for *that* earlier today. It still suffers from the issues I mentioned though. I'm under the impression it was a quick-patch just for the totally broken duplication.

    I don't know how much you know about matrices, but I looked into it a little bit... as for the implementation, you're right, it can be done by treating them as tables within tables. As a tool for just storing information, you're totally correct, you might as well just use a table. But the use of matrices is to manipulate data, perform transforms on vectors, etc. and you can't do that with normal tables, not without lots and lots of inefficient E2 code. Matrix maths is very different to the normal maths you'd do on tables, so currently it's a real pain to do in E2. Think of it like doing lots and lots of complicated vector code with only the basic number functions; it becomes a huge pain very quickly, and it's horribly inefficient.

    The thing is, if you're manipulating objects in 2D space you'd be totally fine without using matrices. But when you start wanting to do interesting things in 3D (i.e. things more complex than just turrets), you want to start using quaternions and matrices to do things efficiently, especially when simple vectors just don't cut it.

    There *is* some quaternion support in there, but there just isn't enough to do anything really useful. I had a look and it's very bare bones, it doesn't have the important functions like modulus and conjugation. To be honest I'd be surprised if anyone, even a mathematician, could find a use for it as-is, without having to do lots of extra manipulation.

    Maybe it's just me... I tend to want to build pretty complex contraptions, whereas most people seem content to slap some thrusters on a car and call it a day! I don't have specific contraptions in mind to use them right away, but as with all these things, once you know the capability's there, you'll start realizing all the things you can use them for. I know for sure I'll find a good use for them pretty quickly. Plus it might give people an incentive to actually learn some maths, right??
    Last edited by Jimlad; 02-05-2009 at 09:40 PM.

  5. #5
    Newbie Programmer ZeikJT will become famous soon enough ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,394

    Default Re: Jimlad's wire addons

    As per the emarker, I looked at your code and it looks good. I think I'm just going to change the way it checks for the entity not existing by adding a gamemode hook instead. So it doesn't have to resort to a think hook at all. The other features look good in code it's a pity I can't test it.
    I've attached the files, please test them if you can and debug them. I just hate think hooks when they are not vital.

    As for matrices, I have used them quite a lot and know they aren't exactly like tables. Gmod as a whole is lacking very much as far as matrices are concerned, aVoN is the only one who got anywhere with them and that's not far at all. There are some functions I'd like to point out that may be of some use to you:
    Code:
    MMatrix	=	{
    	Divide	=	function: 03A02170,
    	Determinant	=	function: 039EF990,
    	Multiply	=	function: 03B4A358,
    	Copy	=	function: 03B3E430,
    	__error	=	function: 03B72660,
    	Trace	=	function: 039EF630,
    	Invert	=	function: 03A076F0,
    	New	=	function: 039F82A0,
    	Sub	=	function: 039C8258,
    	Div	=	function: 03A02170,
    	RotationMatrix	=	function: 039E38A0,
    	Trans	=	function: 03A62428,
    	Adj	=	function: 039CF9F8,
    	__AddAndSubstract	=	function: 03BB01D8,
    	Det	=	function: 039EF990,
    	EulerRotationMatrix	=	function: 039F09E0,
    	Inv	=	function: 03A076F0,
    	Mul	=	function: 03B4A358,
    	Stroke	=	function: 039BB730,
    	__IsMatrix	=	function: 039B2A00,
    	Pow	=	function: 039AB638,
    	Adjugate	=	function: 039CF9F8,
    	Transpose	=	function: 03A62428,
    	Add	=	function: 039CFEC0,
    },
    
    I found this a while back in the gmod code, to be used like MMatrix.Add() and so on, the syntax for which I have no idea. The console errors should help
    You can use console code like this for quicker testing:
    Code:
    lua_run local matrix=MMatrix.New() print(matrix)
    
    It works like your coding in a file but without line breaks.
    You could also just take the code from this lua expansion module: lua-users wiki: Lua Matrix

    For quaternion support I just wanted to make sure you knew the base existed. Build from that as it would be less work.

    I love math and giving me a reason to use it is what wiremod excels at.
    Last edited by ZeikJT; 02-05-2009 at 11:06 PM. Reason: added files
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  6. #6
    Wire Illusionist


    Jimlad will become famous soon enough Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    861

    Default Re: Jimlad's wire addons

    That's awesome! Thanks for having a look. I was also cautious about the Think function which is why I tried to keep it small, but I was going off all the other entities that have one, and I'm just plain ignorant about the relevant gamemode hooks.

    Thanks for the matrix stuff, I wasn't aware it was already in gmod - I figured it came under some sort of addon library that wasn't included, but this will help a lot. btw, is there a quick way of loading .lua files while in-game? I'm so fed up of restart.

    I'm almost tempted to add complex maths as well but I guess I can't justify that, other than in helping to make the quaternion functions. Maybe once I start playing around with the higher level stuff while actually making contraptions, I'll get some new ideas.

    Er, I can't seem to see the attachments you mentioned, where are they?

  7. #7
    Newbie Programmer ZeikJT will become famous soon enough ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,394

    Default Re: Jimlad's wire addons

    Yeah the hook requires adding a new file. Sorry for the missing attachment, I realized I had missed a line of code and hastily took it down to update.

    The two ways of using matrices will work, that addon link has all the code laid out for you, all you'd have to do is adapt it a little. If the gmod functions work already then just use those instead.

    I put the attachment back on that post.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  8. #8
    Wire Illusionist


    Jimlad will become famous soon enough Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    861

    Default Re: Jimlad's wire addons

    ok, I picked up a spelling error in line 4 in emarkerlib.lua, "EntityMarkers".

    But I'm getting a weird error when I spawn a marker, spawn a prop, link them, then undo the prop:

    Hook 'EntityMarkerEntRemoved' Failed: entities/gmod_wire_emarker/init.lua:38: attempt to index local 'self' (a nil value)

    Is that happening because of line 10 in emarkerlib.lua?

    It's pretty late, think I'll go to bed for now since I'm having trouble thinking - thanks a ton for the help though, I'll pick it up in the morning.
    Last edited by Jimlad; 02-05-2009 at 10:55 PM.

  9. #9
    Newbie Programmer ZeikJT will become famous soon enough ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,394

    Default Re: Jimlad's wire addons

    Hmm, im not exactly sure how the SetOverlayText function works as I can't locate it right now. I'm attaching another iteration onto this post, when you get the time test it.

    The previous failing was due to my own ignorance, wouldn't have even posted it had I gotten that error myself as it's an obvious mistake

    If it does fail, go to the server file and look at the commented part I added. Test that too.
    Attached Files
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  10. #10
    Wire Dev - Lazy
    tomb332 has a spectacular aura about tomb332 has a spectacular aura about tomb332's Avatar
    Join Date
    Mar 2007
    Location
    Birmigham,UK
    Posts
    1,384

    Default Re: Jimlad's wire addons

    Yeah the recent updates to the emarker by me where just making it duplicate and nothing more, mostly caused my my lack of time to do stuff atm.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

    Super Easy Wire Download

+ Reply to Thread
Page 1 of 16 1 2 3 11 ... LastLast

LinkBacks (?)

  1. 03-14-2010, 01:27 PM

Similar Threads

  1. A note on inclusion of addons into official wire.
    By Anticept in forum Wiremod Addons
    Replies: 0
    Last Post: 08-18-2008, 06:13 AM
  2. Addons for Wire Mod, mods for Wire Addon
    By _Kilburn in forum Wiremod Addons
    Replies: 60
    Last Post: 07-18-2008, 08:40 PM
  3. Addons for a Mac?
    By FOXDONUT in forum Wiremod General Chat
    Replies: 18
    Last Post: 06-11-2008, 02:43 PM
  4. The [Table] |Lots of Addons|PHX|SVN Wire|SVN Wire2|
    By LemmingsOwnYou in forum Servers
    Replies: 0
    Last Post: 09-14-2007, 06:16 AM
  5. Combining Wire Addons into the main package
    By Maximized in forum Ideas & Suggestions
    Replies: 1
    Last Post: 02-21-2007, 02:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots