![]() |
_indexof2
Make a second version of all the _indexof functions such that they are CaSE seNsItIVE.
|
Hmm. I'm sure it has many uses, but I can't seem to think of any...
|
Well, the base 64 system Stefan created to deal with storing tiles is case sensitive.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
I am positive indexof is a far cry more efficient that a ton of ifs trying to figure out the decimal value of the letter.
|
Quote:
|
Still, far better 1 line as opposed to 64 virtually identical if clauses
I can create a string, call it this.values, and arrange all the characters such that their position in the string is their decimal value. However, for this to work right, indexof needs to differentiate between G and g. Since I don't have access to v3 engine, I can't do a switch statement, which would still be quite a bit longer. So, I am stuck with NPC Code: over and over again |
Quote:
Quote:
|
Would you care to explain how three to four ifs could allow me to convert one of 64 characters into their decimal equivalents?
Secondly, how is it at all inefficient to condense those ifs into a single indexof? |
Quote:
Quote:
|
So, you admit, you just aren't adding three ifs, you are adding other things. And these "ranges" how would you define them?
As for the length of the script, no, I think it is a lot more efficient to say "where is it located?" than several "is it this? No? Well is it that?" indexof may start to be a less efficient piece of code when used 10000 times; but, from what I have seen of differences in efficiency at this level of iteration, I doubt that it's going to be a problem. |
Quote:
Quote:
Quote:
Quote:
2) When used 10,000 times, huh? Tell me, what are you going to do with this base64 stuff? Could it be that you intend to iterate through 4096 tile specifications? |
Quote:
Quote:
|
Quote:
Quote:
If you want to try to justify bad code then be my guest. Perhaps you don't realise the greater consequences. |
Quote:
It really sounds as if you want to do something very similar to what I am doing except in pieces rather than just in one step. |
Quote:
Quote:
Indexof examines each character of the source string, looking for a match between it and the argument you provide. One by one. Like 64 little ifs. That's not what I'm suggesting. Once you've divided the string into ranges, you can do all the numerical manipulation with a couple of elements of arithmatic. |
Quote:
|
Quote:
|
Ah. I see ASCII value. Hrm.
Yeah you could do it that way. Doesn't seem very versatile. My way, to change the system, you just change the string. Your way, you'd have to rearrange all the ifs. Sure, I'm being hypothetical here, but there it is. |
Quote:
|
No, but suppose I want to create my own encryption system? It would be a piece of cake to tweak the code I already have.
You might say I am the scripting world's answer to Junkyard Wars (Scrapheap Challenge in UK). I love cannibalizing code. |
Quote:
1) Your scripts will be less efficient as a result. 2) You won't consider all the possible approaches; you'll automatically choose one that involves some previous script. |
Clearly I don't cannibalize everything, or I wouldn't need new functions. I just like cannibalizable code. Everything worth coding has multiple uses.
|
Quote:
|
Wait a second. Are you straw-manning?
In your opinion, more poorly. Yes. In the opinion of the computer science world, sure. In my mind, more versatile is better than more precise. I am willing to sacrifice efficiency on a small scale to make the script more useful |
Quote:
Quote:
A good coder isn't somebody who uses a hammer and crowbar to wedge his old code into somewhere it doesn't fit. A good coder designs each solution to fit a single problem, and draws on old creations only when they match the design he crafts beforehand. |
Lol. This is why I am a mathematician instead of a computer scientist. But you have to admit, I don't do too badly for only taking one class.
On the other hand, I wouldn't exactly call it hammering a square peg into a round hole. It's more like I like to use clay pegs. Let me give you an example. I coded a window display routine for SA. This code allowed Soul to make the window any size he wanted, within reason. After finishing that, I realised that the script had other potential. I converted it from an image tiler to a tile tiler. In the matter of about two minutes I had created a whole new use for the same script. |
Quote:
Quote:
|
| All times are GMT +2. The time now is 03:24 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.