You like?
OMG ty so fn much!!!
 0%  [ 0 ]
Neeto?
 0%  [ 0 ]
Not interested
 100%  [ 2 ]
Total Votes : 2

This is a plugin I have been working diligently on. So far everything is working fabulously. I have been scripting an Adventure Dungeon with all new puzzles available due to the lack of wiring necessary and bypassing the limits of pistons by removing blocks altogether (or vice versa). Scriptable blocks only interfere with normal operation when they have set to do so.

Readme:

Code:
portals.flat:
   Flat-file storing button locations and scripts. Size varies on command script length.
   
Stone Buttons and Stone pressure plates are currently the only scriptable blocks. Destroying a block holding a scripting block (ultimately destroying the scripted blocks) will not destroy the portal, allowing players to place a button or plate that takes on the script of the previous block.
Alternatively, "rblk <world> <x> <y> <z> 0" can destroy the block without destroying the portal.
IMPORTANT: the use of $ on both ends of a variable prevents a shorter variable from overwriting
   ex: $MyPlayer might get overwritten if a pre-existing variable $My existed
   Forgetting the 2nd $ is a costly mistake!

%t - replaced in the initial script with the target players name
%w - replaced in the initial script with the target players world name
$var$ - replaced in scripts with the variable if it exists. exists as a string if not (fails < or > checks)
   by technicality, this supports arrays...
*Note* %t and %w are replaced before $var$ is ("$%t$" will look for the variable $PlayerName$)

*Note* All commands are cross-world compatible
Commands:
   Players:
      /btn - scripts the next placed scriptable block as a teliporter to the destination suggested when typing the command
      /btn <script> - script the next placed scriptable block with <script>
   Server:
      /add <script> - add script to the end of the target-blocks script (create if it does not exist)
      /set <var> <val> ("set %t.score 0") will allow you to set $PlayerName.score$ as a variable to use in scripted commands.
      /inc <var> <val> ("inc %t.score 1") will increase $PlayerName.score$ by 1 (will not work with non-integral variables).
      /dec <var> <val> ("dec %t.score 1") will decrease $PlayerName.score$ by 1 (follows rules of !inc)
      /sendplyr <string PlayerName> <string world_name> <double x> <double y> <double z> - teleports a player to a new location
         *Note* teleporting using pressure-plates may kick the player from protected servers
      /rblk <world> <x> <y> <z> <blockid|blockname> - replace a single block
      /rcube <world> <x> <y> <z> <x2> <y2> <z2> <blockid|blockname> - replace all blocks from location 1 to location 2 in a 3 dimensional space

Scripts:
   !break will stop the entire script from running.
   !if <var1> eq <var2> true-command|false-command ("!if $%t.score$ < 5 kill %t|dec %t.score 5") will allow for a true-false command.
      false-command not necessary ex: ("!if %t == PlayerName op %t;")
      In said case, if the players score < 5, the player will be killed.
      Adversely, it will decrease the players score by 5
      *Note* If the variable was not set by another block, the value will null-out, doing nothing.
         "!if $PlayerName.score$ < 5 kill PlayerName|dec PlayerName.score 5" rather than "!if 0 < 5 kill PlayerName|dec PlayerName.score 5"
         "$PlayerName.score$" < "5" cannot parse because values are strings rather than integers
      *Note* ";" cannot be used in an if-then-else statement to break commands

";" - signify end-line for a command, allowing infinite commands to run back-to-back

Updates:
    set, inc, and dec have been changed to slash commands to allow their use in !if statements.
    subsequently added to allow numerically limited multi-presses
   
ToDo:
   /tmr <seconds> <scipt> - run a delay before activating a single script line
   variables.flat - Flat-file storing variables and values
   handle multiple if-true and if-false commands
      ex: "!if $%t.score$ >= 100 inc %t.score 10;msg %t Perfect Bonus, 10 points!|inc %t.score 1;msg %t Not perfect, but you did well!"
   replace unknown $var$s as "null"
   increase number of scriptable blocks (doors, levers, etc)
   convert commands pulled from alternative plugins to here


Video depicting possible creations due to scriptable blocks coming soon!
Currently, my code looping goes a lot like this:


Code:

String script = teleporter.portal.get(loc); // get script for block
... // replace static variables %t and %w
String[] com = script.split("[;]"); // break separate lines
for (int i = 0; i < com.length; i++) { // for each command line check
   ... // replace dynamic variables
   if (com[i].startsWith("!")) { // if it's a runtime command
      String[] args = com[i].split("[ ]"); // split the line up, seperate arguments by spaces
      if (args[0].equals("!if")) { // if it's a run-time !if command
         boolean IsTrue = false;
         List<String> matches = new ArrayList<String>();
         matches.add(args[0]); // !if
         matches.add(args[1]); // 'arg1'
         matches.add(args[2]); // ==
         matches.add(args[3]); // 'arg2'
         String commands = "";
         for (int j = 4; j < args.length; j++) {
            if (j == 4) {
               commands += args[j];
            } else {
               commands += " " + args[j];
            }
         }
         String[] IfElse = commands.split("[|]");
         if (IfElse.length == 0) {
            return; // cannot contain no if-else command
         } else if (IfElse.length == 1) {
            // if-then statement
            matches.add(IfElse[0]);
         } else if (IfElse.length == 2) {
            // if-then-else statement
            matches.add(IfElse[0]);
            matches.add(IfElse[1]);
         }
         ... // handle true/false checks
      }
   } else { // it's a slash command
      plug.getServer().dispatchCommand(Bukkit.getConsoleSender(), com[i]); // send command to server
   }
}


first it uses "[;]" (semi-colon) as a line breaker. If commands use "[|]" (break) as a true-false command separator. I either need yet another line-splitter, or an altered way of converting a string of combined commands to run-time code. Or perhaps a function that does all of this? What do you think a clean, and productive method to this is?

I would like to be able to use something like this:
[1 commands] "!if %t == Komak57 { msg %t Hey boss!;op %t; } else { heal %t; }"
but the scripting method would read
[5 commands]"!if %t == Komak57 { msg %t Hey boss!", "op %t", "} else {", "heal %t", "}"

adversely, I would also like to be able to use something like:
"!if %t == Komak57 { msg %t Hey boss!;op %t; } else { !if %t.score >= 5 { dec %t.score 5; heal %t; } }"
if Komak57 presses the button, it messages him "Hey boss!", then ops. If anyone else presses the button, and they have a score over or equal to 5, decrease their score, then heal them.

currently, I can't even write a script that handles 2 different checks with 2 different variables with 2 different scripts (unless the first check also benefitted the 2nd check) even with the !break. Best I can do is do 2 checks on the same variable? much less

-- Update --
I'm starting to wonder if i should leave String script as it is before variables, then regex from the start of the string to determine what kind of function it is, strip it out, and handle everything completely different? All in a new function that allows any event to call it?

-- Update --
It has been decided that I will be writing my own Recursive Descent Parser to evaluate all of my code appropriately... I'm fairly new to writing my own language, and using a pre-made one may cause unnecessary parsed lines that may slow the server, but I am familiar with grammar and code logic. I should be fine XD... maybe

For those of you that don't know what it is: http://math.hws.edu/javanotes/c9/s5.html

This will fix quite a few future planned things on my ToDo list, as well as enable far greater control over the block scripts. I could use help from people pointing me in the right direction if you have a moment ^.^ (just throw me some google links)

But on another note, I would like to convert my portals.flat to a portals.ini to allow manual editing of scripts or block locations...
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement