New account registration is temporarily disabled.
  • Add Review
  • Subscribe
  • Nominate
  • Submit Media
  • RSS

Got rid of the programmer's block RRRRR!

I've finally got the code blocks and jumps working so that the following runs correctly. I had this overly complicated and horrible jump map character library all set up when all I needed was to match braces.

You see, when the executive reaches an if statement, there will always be a { after it. If the value inside is true, it just skips the {. Otherwise, the { increments a block level variable. If the block variable is not zero, codes are ignored. } decrements the variable and negative numbers are just set back to zero.

This actually effectively works for both normal and nested blocks like this. I can't believe how simple the solution should have been! The only problem is that {} must be on their own line and you can only have one per line.

Here's an example of what code blocks are:


// WeaponBirth Test NPCs

// This NPC remembers the player
test_kitty_npc:

1.examine
// Count the number of times the player has talked to the NPC
speaker("Kitty");
add(counter,1);
show_value(0,counter);
show_message("You've talked to me @0 times.");
if counter > 4
{
// On the 5th time, vanish
show_message("Alright, this is annoying now... I'm out of here!");
delete();
}