Jump to content
Sign in to follow this  
dreadedentity

[CODE SNIPPET] Decimal to base any encoder and decoder && vehicle diagnostic tool

Recommended Posts

Hello everyone!

It's been some time since I've done a code snippet, I've been busy with other projects and life stuff. But I'm here today and I have something really cool things to show off (in my opinion). This code snippet will be a little more intense than my other ones, which were mostly just fun little arma things or short tutorials. So without further delay, here I go:

Well, you did read the title correctly. One of my favorite things to do with code is loops. They're a bitch, but I love them. Today I've got 2 really neat functions, one is for converting a decimal number to ANY base (binary (base2), ternary(base3), base 10 (decimal, not sure why you'd convert from decimal to decimal though), hexadecimal, octodecimal) and the other is to convert that data back into decimal. I don't personally have a use for them, I was just having a little fun with the engine (somehow I've turned this game into a glorified calculator). It all started with my other little script that I wanted to show off.

I played the DayZ mod for a great long time (a really long time), I played it for about a year before I even noticed that there was still another entire game that I hadn't played. Anyway, Rocket had vehicles in there that you had to fix up, and actions were shown in different colors depending on how damaged they were. Well guess who was able to reproduce this? That's right, see my video just below this.



Now, I do realize that this isn't quite the same setup Rocket had, but I think it's a really good starting point. For some reason, however, I had to code in some error handling because some hitpoints were not showing up properly, despite being ripped off directly from the configfile, how strange! You can see that when I look at the hatchback and the light blue "NOT FOUND", I had to do that because otherwise it messed up my structured text and was just all around not very pretty.

Alright, so in both of these scripts there are a few problems. For the Vehicle Diagnostic Tool I already talked about that, something's wrong with scraping the config info. Now in the encode/decode script, I'm not sure how many people know about Arma's rounding issues, but it's pretty bad. I've complained enough about it for one lifetime, though, so I won't say anything more. While writing those 2 functions, I was trying to get around the rounding so there ended up being a lot of strings and things dealing with them, the problem is there's always a failure point though. To make a long story short I'll get to the point, there is a maximum amount of characters that can be input before BOTH the encoder and decoder become unreliable. To circumvent this, I recommend splitting up larger numbers and saving them separately, you can then decode them with no problem and just stick 'em back together, like reattaching a loaf of bread that's been cut in half.

Well, I guess I'll be off now. Keep up the good work, and please, don't forget to have fun along the way.

Download:



Vehicle Diagnostic Tool | BaseAnyEncoderDecoder

(both are dropbox links)

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×