|
| |||||||
| Wiremod Tutorials Post your wiremod tutorials/guides here. |
![]() |
| | LinkBack (21) | Thread Tools | Display Modes |
| |
#1 (permalink)
|
| Advanced Member ![]() Join Date: Apr 2008
Posts: 138
![]() | Note: By releasing my videos along with e-gate code I am trying to help new people to wiremod think how they can develop their contraptions by letting them study my reference code. This is not done to explain how different tools work , you can watch Revan's video tutorials for detailed explanations on how everything works. I will be rewriting the first gate to get rid of code nesting so that you get a clearer picture of how proper code should be. Simulating Hoverballs using 1 Thruster. You can see where everything is positioned , what you also need to know is that the thruster has to be bi - directional (it has a multiplier of 55) and the numpad inputs have toggle unticked. Oh i almost forgot the most important part , my e-gate's code : N@Hovering I@Z Num8 Num5 O@Thrust Line1: Height = (Num8 ? 2 + (Num8 ? Height += 1 : 0) : Height), (Num5 ? -2 + (Num5 ? Height += 1 : 0) : Height) Line2: Thrust = (Height - Z) - $Z Now for intermediate users do not worry about the Height variable not being outputed , its only used in the E-gate for the calculations and basically is the height that we want our plate to hover at , as for Line2 its pretty self explanatory and $Z is the delta of the movement in the Z axis in other words $Z is the acceleration of our plate in the z axis and it has to be removed from the thrust so that the plate doesnt go crazy moving up and down endlessly by itself. Now what can i say about Line1 , that is a line that in my opinion can be only understood by advanced users since it took me like 3 hours to finish and even when i look at it right now i get confused . Please do not criticize me if this has been done before , i personally havent seen any other similar tut except for Xtensity's and i only wanted to imrpove his idea , also I want you to know that i had never used delta before and its the first time that i attempt this having followed no tutorial on thruster stabilization , hope it helps. ------------------------------------------------------------ New all in one e-gate and different hover control system. This time , inspired by Revan's accumulator tutorial i decided to use it on my controllable hovering plate. You can see all the stuff needed for it at the video. Keep in mind the code is a lot cleaner this time and using the accumulator you get smoother movement. Code for the e-gate used in my video: N@Numpad 8 5 Hover Controller I@Num8 Num5 Accum Z O@Run Reset Thrust Line1:Reset = (Num8 + Num5 == 0 ? 1 : 0) Line2:Run = (Num8 ? 1 : 0) + (Num5 == -1 ? -1 : 0) Line3:Height = (Num8 ? Increasement : Height) Line4:Height = (Num5 == -1 ? Increasement : Height) Line5:Thrust = (Height - Z) - 4 * $Z Line6:Increasement = (Accum != 0 ? Height + 4 * Accum : Height) ----------------------------------------------------------- Fully Stabilizing a plate using a gyroscope , 1 expression gate and 4 thrusters. You can see the whole process at the video , one thing i would like to make clear is that you should make sure your thruster multiplier is around 5. Also be careful at how i keep checking my gyro's pitch and roll and my expression gate as well , I do that to see what thruster is what and to make things simplier lets put it this way. While rotating the plate to check your Pitch there will be one thruster at one side which is at a lower height than the other , if then your pitch is negative you will have to wire that thruster to the Forward output of the gate , if the pitch is positive wire it to the Back output instead. Same goes for Roll , bend your plate to check your gyro's roll , one thruster at one side will be at a lower height again , if the roll is then negative wire that thruster to the Right output of the gate , if roll is positive then wire to Left output instead. Expression Gate Code used : N@Pitch Roll Stabilizer I@ Pitch Roll O@Back Forward Left Right Line1:Back = Pitch + (2 * $Pitch) Line2:Forward = -Pitch - (2 * $Pitch) Line3:Left = Roll + (2 * $Roll) Line4:Right = -Roll - (2 * $Roll) ---------------------------------------------------------- Delta Chip Explanation (more in depth) - kept simple Yea i took a break off Expression gates and made this , sorry for the red rope not being visible on the ground at the beginning I hadnt estimated that and excuse my poor vocabulary i am not english. One thing that you should really be carefull at is that : - Even though the Bearing is positive the Delta can still be negative and again when the Bearing is negative the Delta can still be positive. I would like to correct myself at a certain spot wher i said what the Delta is , Delta is the how fast a value changes along with whether the change is negative or positive . A few tips : the Delta of a value in expression code it written this way: If "A" is a variable which corresponds to a certain value the Delta of that value is "$A" . When it comes to movement of objects using thrusters the Delta is always neccecary to make your contaption move without any glitch or spasm, why is that? Well if you think perspectively Delta is the acceleration of a value ( acceleration in physics is change of speed in meters per second ) just that you are not counting meters per second but a certain value (like the bearing or the elevation or the pitch or the roll) per 1/10 of a second (i think its 1/10 of a second but definitely something close to that) also the Delta can understand whether the change is negative or positive so it will change its sign by itself. And the truth is that what makes things that move using thrusters spasm out of control is the acceleration so we use the delta to get the acceleration removed automatically when not needed or added when needed. --------------------------------------------------------- In-Game Numpad Simulation Expression code : N@Numpad I@One Two Three Four Five Six Seven Eight Nine Zero Reset O@Final A = (Times==1 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) B = (Times==2 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) C = (Times==3 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) D = (Times==4 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) E = (Times==5 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) Button = (One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Zero ? 1 : 0) Button -> Times += 1; Reset -> Times = 1, A1 = 0, B1 = 0, C1 = 0, D1 = 0, E1=0, Final = 0; A -> A1 = A; B -> B1 = B; C -> C1 = C; D -> D1 = D; E -> E1 = E; F == 0 -> F1 = F; Times==1 -> Number = (A1)+ F1; Times==2 -> Number = (10*A1)+B1 + F1; Times==3 -> Number = (100*A1)+(10*B1)+C1 + F1; Times==4 -> Number = (1000*A1)+(100*B1)+(10*C1)+D1+F1; Times==5 -> Number = (10000*A1)+(1000*B1)+(100*C1)+(10*D1)+E1+F1; Button -> Final = Number / 10; Zero -> F = 0; So as you can see even though such a numpad in game is nothing special the code for it in 1 expression gate is quite advanced. Now to comprehend how it works you more likely have to have some maths knoweldge regarding 1 , 2 , 3 ,4 digit numbers and so on but I am still gonna try and explain it to ya the simpliest way possible. Lets start off with this part: Button = (One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Zero ? 1 : 0) Button -> Times += 1; First line means that if any of the number buttons pressed , Button variable will equal 1 , and then every time it equals 1 the Times variable will increment itself by 1. This is done to make the gate "understand" the order of buttons pressed. Lets now get to : A = (Times==1 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) B = (Times==2 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) C = (Times==3 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) D = (Times==4 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) E = (Times==5 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) Here i take advantage of my previous code, since the gate knows how many times ive pressed the buttons i used this piece of code to include the order of the buttons pressed along with the number itself that was pressed at that time in 1 variable per button press. Next piece: A -> A1 = A; B -> B1 = B; C -> C1 = C; D -> D1 = D; E -> E1 = E; F == 0 -> F1 = F; This is what I did to create a temporary memory inside the gate so that it remembers which numbers where pressed . Basically what i did is i stored the older variables (which would revert back to 0 when then button would be released) into new ones which will keep the older data inside them until i reset them. Next piece: Times==1 -> Number = (A1)+ F1; Times==2 -> Number = (10*A1)+B1 + F1; Times==3 -> Number = (100*A1)+(10*B1)+C1 + F1; Times==4 -> Number = (1000*A1)+(100*B1)+(10*C1)+D1+F1; Times==5 -> Number = (10000*A1)+(1000*B1)+(100*C1)+(10*D1)+E1+F1; Button -> Final = Number / 10; This is where maths knoweldge comes in handy, so if i asked you what number 356 is made of u would most likely tell me its made of a 3 , a 5 and a 6, well to tell the truth thats wrong. Number 356 is made of a hundred times 3 (100*3), ten times 5 (10*5) and 1 times 6 (6) or (1*6) if u add them all together u get 356, if u added 3 , 5 , 6 together u would get 14. So this is how u can express multi digit numbers in maths. Now after u have understood how to do that i had to make the gate understand that the first time that i press a button (in other words Times = 1) the final number given would be a 1 digit number , the second one it would be a 2 digit number so for something like 35 i would have ten times 3 (10*3) and one times 5 (1*5) or (5), the third time i would have a 3 digit number so i would have the same as the example i used for multi digit numbers in maths. As for that line at the end , i am using it to get rid of extra "0"s after numbers pressed and in my opinion that last bit is the hardest part of my whole code to understand , it was quite hard for me to figure out and i still need to work on that line to get the numpad to show 5 or more digits numbers as well. This line right here : Reset -> Times = 1, A1 = 0, B1 = 0, C1 = 0, D1 = 0, E1=0, Final = 0; Is just the reset code that i am using which will reset everything pressed by turning my "memory" variables back to 0 as well as reseting the times per button press. By now you should be wondering what is this line "Zero -> F = 0;" and why isnt button 0 in the "A = (Times==1 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) B = (Times==2 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) C = (Times==3 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) D = (Times==4 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0) E = (Times==5 ? One+Two+Three+Four+Five+Six+Seven+Eight+Nine :0)" lines, well since zero is zero and nothing can work when such a value is outputted i made it output 1 as shown in the video and decluded it from the original code so that it doesnt get mseed up with button 1. Still i am using the "Zero -> F = 0;" line to transform the value that will be used by the expression gate into what i need , the 0 value gets normally stored as u can see in the memory lines and then its also added in the last piece of code where the magic happens but ONLY WHEN button 0 itself is pressed.
__________________ ![]() ![]() Last edited by Aspras; 05-14-2008 at 09:46 AM.. |
| | |
| Sponsored Links | |
| | #2 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 129
![]() | don't know what your trying to say but you can alter the height in the one I made flawlessly, it goes up and down without turbulence and works great. Yours looks the exact same as mine lol. |
| | |
| | #3 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 138
![]() | It does go up and down but for example can u increase its height and then reincrease it ? In your occasion if the plate was hovering at 50 you would be able to make it go up to 60 and then down to 40 but would it go up to 70 or 80 without changing the value in your e-gate but just using numpad?
__________________ ![]() ![]() |
| | |
| | #4 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 129
![]() | Wtf are you talking about. I can make it go to any height I want it to by using number pad. It depends on what number pad I'm using. If I was using advanced input it would simply add that number to the number inside the thing and when I change the number it would change accordingly. I'm using Dual input though because I can have 2 keys, (-) and (+) (+) adds 10 while (-) adds -10, or subtracts 10, same thing. |
| | |
| | #5 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 138
![]() | Well you didnt show that in your video so i thought your plate could move up and down within a range of 10 from the predefined height. In that case lets say i recreated an expression gate doing the same thing lol.
__________________ ![]() ![]() Last edited by Aspras; 05-05-2008 at 09:21 AM.. |
| | |
| | #8 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 138
![]() | Yea your plate is stable but i am not talking about the plate ( regardless the fact that ive made 2 diff video tuts on how to make a plate hover with 2 different ways) I had to go into detail in the Delta one which also has voice because i think tutorials that have been released till now are kind of basic judging by Revan's video tut where he used a button , it wasnt bad but it made delta look like a substraction chip so i wanted to show the true potential of delta so that everyone can see how it calculates change in values when it comes to really fast and varied value changes. PS: I tried to change the title of the thread so that people know i am posting video guides along with e-gate code for different stuff but it doesnt wanna change : / .
__________________ ![]() ![]() |
| | |
| | #9 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 129
![]() | All delta is is rate of change a second lol or ((New-Old)/New)*10 Edit, to fix your trouble shooting. Turn the plate like so you would see it like this == from the top and [] from the side like if your looking out. Then when you place things like beacon sensor on it when its up like that they will be 100% straight, and gyroscope will go on their 100% perfect. When you place the gyro, the side near your feet is the pitch side so yeah it works great Last edited by Xtensity; 05-09-2008 at 09:29 PM.. |
| | |
| | #10 (permalink) |
| Advanced Member ![]() Join Date: Apr 2008
Posts: 138
![]() | Its not a second , watch the video i made , if the update rate was a second then the value of delta would only change every 1 second , and that delta changes a lot faster than once per second.
__________________ ![]() ![]() |
| | |
| Sponsored Links | |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vector Thrusters vs Wire Thrusters | Ergzay | Help & Support | 6 | 05-28-2008 01:13 PM |
| Hoverball help | Gore-wrath | |||