Author Topic: Stuck...  (Read 2447 times)

I need to see if the Guis & Ui works on other computers.
...no you don't. You're not writing in some low-level language that could be affected by different CPU instruction sets or whatever other hardware differences, you're writing in a very high-level language that is interpreted by Blockland. If a computer runs blockland, it'll run your add-ons. The only possible difference is whether it looks fine in a smaller resolution, which you can change yourself.

Also a GUI is a type of UI, and since I don't your making a command line interface or other type of interface within blockland, saying "GUIs and UIs" in redundant
« Last Edit: June 22, 2014, 04:24:32 PM by Headcrab Zombie »

You should do neither of these, at least not in this case.
Check name, then check msg in a nested block. The way he's doing it now, and the way you suggested, makes more comparisons. More comparisons = less efficient, and optimization is a good habit, even when it won't make any noticeable difference
Nested ifs can't replace an or, and nested ifs to replace an and looks disgusting with more than two conditions (or arguably even one). You can call it "your own style" as much as you like, but that won't change the fact that any experienced programmer is going to hate it
So I shouldn't use nested if statements or the || and &&? Then what am I supposed to use?

So I shouldn't use nested if statements or the || and &&? Then what am I supposed to use?
I answered this question on literally the very next sentence, do you even read?
I'll assume the answer is yes and that you just didn't understand it. so I'll explain it even further for you with some psuedocode


You said to replace:

if condition one
   if condition two
   end
end
if condition one
   if condition two
   end
end
if condition one
   if condition two
   end
end
...


with:

if condition1 and condition1
end
if condition1 and condition2
end
if condition1 and condition2
end


I said neither of these are good, because both are inefficient, making multiple unnecessary comparisons. I said you should do this instead
if condition2
   if condition1
   end
   if condition1
   end
   if condition1
   end
end
« Last Edit: June 22, 2014, 04:45:36 PM by Headcrab Zombie »

Let's not forget about switch$(%msg)

Let's not forget about switch$(%msg)
That ends up being about the same as a if/else if/else if/else block, it just looks better in the code.

Hey, I know I'm kinda new to this coding, but How do you use switch$(%msg)?
Example Please?

function Reply(%c)
{
   switch$(%c)
   {
      case "hi":
         echo("You reply \"Hi\" back!");
      case "thank you":
         echo("You reply \"You're welcome\" back!");
      default:
         echo("Uh oh! There is no response to this one!");
   }
}

That ends up being about the same as a if/else if/else if/else block, it just looks better in the code.
And an if/else if/else if/else block is still better than if/if/if, seeing how if x = "hi", x sure as hell isn't going to = "bye" unless by some miracle (or functionality for a different type of mod) it changes before the next check, no point in checking. And that's just what else/else if does, doesn't check so long as any previous ifs in the chain were true.