This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
negamartin's profile picture

Virtual Parkour

Started by negamartin, 29 June 2015 - 07:29 PM
negamartin #1
Posted 29 June 2015 - 09:29 PM
After seeing Lion4ever's parkour, I thought about making a modular parkour, where anyone can make parts and mix them together.
So I made a type of parkour, where different structures are plugged together.
Basically this is a program that loads other programs that feed the main program structures so the main program can put them together. :P/>
So you dont have to do the dirty work.

Every structure is an external file, which is loaded and used to make a parkour.
For example, you could have a structure which is one floating block, and a structure of a floating block with a ladder.
Then, you would find floating blocks and ladders forming a path for you to jump.

The idea is that people make their own structures, and upload them to the centralized store.
Then anyone can just download and use them.

Main Features-Modular, easy-to-make structures, the easiest way is to edit one of the already made ones.
-Multiplayer and different gamemodes, where every player plays the exact same parkour.
-Monitor interface, no deleting/downloading, for survival or non-OP players.
-Takes into account that players may have items before playing, and as such, stores them safely before starting.
-Configurable with "parkour_config"
-Enabling/Disabling of structures to create your customized parkour.
-Structure store, with structure versioning and descriptions.
-Changeable difficulty


Images


Main monitor interface.


Main computer interface.


The store.


Monitor player selection.


Inside the parkour.



Structure Development Guide

This is actually more of a tutorial. This is updated to V1.2
Please play the parkour before reading the guide. It will help you understand how it works.
The guide assumes you know lua and lua tables.


Every structure file is just a lua program that returns a table.
Your lua file will be run, and will be expected to return special results, that define your structure.
First of all, the most basic structure would be like this:

	args={...}
	if args[1]=="build" then
	  return [structure table here]
	end
Exactly what is expected for your script to do, is contained in the arguments, which you can obtain using {…}.
The first element of this table will always be a string, and will be one of a set of strings.
But the one we are interested in is "build".
When your script is called with a "build" argument, you must return a structure table, which in turn must contain a series of element in it:

First we will start with blocks.
The blocks table contains a other tables, which represent every block in the structure.
An example would be:

	{
	  {0,0,0,"stone"},
	  {1,0,0,"stone"}
	}
The first, second and third element in a block are the XYZ coordinates. The fourth is the string id, and so on, according to setblock parameters.
Every structure has a checkpoint, the obsidian block.
The coordinate 0,0,0 is the checkpoint block from the structure before yours.
Sometime the checkpoint of the structure before yours is replaced with an obsidian block. In this case it is obvious were the checkpoint is.
Even when the obsidian block isn't there, the checkpoint is there, as an abstract location.
The coordinate 1,0,0 is one block FORWARD the previous structures' checkpoint (the ocasional obsidian block).
What this would do, is turn this:

into this:

To actually implement this you would do:

	args={...}
	if args[1]=="build" then
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		}
	  }
	end
Usually you dont use 0,0,0 in your blocks table, since it would replace the previous' structure obsidian block/checkpoint (which may have a non-obsidian block).
Since the elements in the table are the arguments fed to setblock, you can feed meta, oldblockhandling and NBT tags.
Just make sure the first 3 elements are numbers.

The next one is areaCheck:
This is a table of tables, just like blocks, but the function of this one is to check you are inside the structure and haven't fallen.
Example:

   {
	  {0,0,0,5},
	  {3,0,0,4}
   }
This makes it so that only if you are outside a 5-radius sphere centered on 0,0,0 and also outside a 4-radius sphere centered on 3,0,0, you are considered "dead", teleported back to the previous checkpoint and added 1 death to your counter.
So to implement both blocks and areaCheck:

	args={...}
	if args[1]=="build" then
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		},
		areaCheck={
		  {0,0,0,5},
		  {3,0,0,4}
		}
	  }
	end

The next is exit:
Exit is the place of your checkpoint, (the ocasional obsidian block), the block that will be considered 0,0,0 for the following structure.
So, remember we had stone on 0,0,0 and 1,0,0?
Now the checkpoint will be in 2,0,0, so if the parkour places an obsidian in our checkpoint we will make a line of blocks:

This would be done as such:

	{2,0,0}
So the complete program is:

	args={...}
	if args[1]=="build" then
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		},
		areaCheck={
		  {0,0,0,5},
		  {3,0,0,4}
		},
		exit={2,0,0}
	  }
	end
Also, now if we reach the obsidian on 2,0,0, we will register a checkpoint and generate the next set of structures.
If there is no obsidian in 2,0,0 (the parkour didn't decide to put a checkpoint) you will just be able to jump from there to the next structure, maybe even another of your structures.
The obsidian is autoplaced on your exit coordinate when a checkpoint has to be placed, so make sure you plan for it.

The next one is "next":
Our structure is just a straight line, but what if it turned to the right? How would the next structure know?
'next' does this.
The parkour understands 4 orientations:


	 z-
x-		x+	-> Forward
	 z+
  

The parkour program handles all the rotations. You just need to give it orientations.
The "forward" orientation is "x+", which means that if you set "next" to "x+", no direction change will apply.
But if we want the next structure to be 90° to the right, we would set next to "z+".
Or if we wanted it to be just in the opposite direction we started (eg. our structure is a U-turn) we would set next to "x-".
For this example, we will set it to "z-", and make the next structure be 90° to the left(counterclockwise).

	next="z-"
So the complete structure is:

	args={...}
	if args[1]=="build" then
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		},
		areaCheck={
		  {0,0,0,5},
		  {3,0,0,4}
		},
		exit={2,0,0},
		next="z-"
	  }
	end
BUT, if you take a look into floating_blocks, you will notice next isn't set to any string, but instead to a number.
This is because floating blocks(and most structures) work with angles, and the next structure must know the previous' structure angle.
How does this work? With numbered next values.
Look carefully at this image:

So the structure chooses a new angle based on the previous angle, and feeds it into the next structure through "next".
The next structure can get this value through args[2] (it is the second argument fed to the structure when "build"ing)
So to get the previous angle, turn a little to the right, and feed it into the next structure:

		args={...}
	if args[1]=="build" then
		  previousAngle=args[2]
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		},
		areaCheck={
		  {0,0,0,5},
		  {3,0,0,4}
		},
		exit={2,0,0},
		next=previousAngle+0.2
	  }
	end
The angles must be in radians.

And finally, the easiest one of all: "length".
Length is just the difficulty of your structure. 100 means a checkpoint should be placed right after this structure.
1 means that 100 structures should be built before the next checkpoint, 50 means 2 structures should be built before the checkpoint, etc…
This is all in normal difficulty. Normal difficulty has a "checkpointStride" of 100, which means that 100 structures of length 1 should be placed before the next checkpoint.
Hard has a checkpoint stride of 150, and easy has a checkpoint stride of 60. This means the harder your structure is, the higher your length should be.
It would be like this:

	length=10
  
And to implement it, it would be like this:

		args={...}
	if args[1]=="build" then
		  previousAngle=args[2]
	  return {
		blocks={
		  {0,0,0,"stone"},
		  {1,0,0,"stone"}
		},
		areaCheck={
		  {0,0,0,5},
		  {3,0,0,4}
		},
		exit={2,0,0},
		next=previousAngle+0.2,
		length=10
	  }
	end
  



You can copy paste it into "/stuctures/guide" (or even better, write it yourself) and then run the parkour with 'Guide' activated to see what happens.
You can also download and check 'Floating Blocks', which is heavily commented to explain how it works. You are also free to modify it to create your own, you dont have to credit me.


To download V1.21(latest), use

pastebin get wbW5e1ZD parkour
And then run

parkour
Or edit your startup to run it when booting, in case you want non-OPs to use it.
Or, if you had the parkour previously, just let it update, it will try to do it by itself.

And if you reached the bottom of this post, and didn't understand anything, just give it a try and you'll very probably understand.
Stupid color tags.
Edited on 13 September 2015 - 03:37 PM
negamartin #2
Posted 09 July 2015 - 03:54 PM
Well, I don't know if someone is even looking at this, but I have updated it.
It should auto-update.
Changelog-Beautiful and colorful text
-Custom areaCheck callbacks
-Micro Structures!
-Quicker response times
-'Compile Time' errors now properly show when testing structures
-Hunger now regenerates automatically
-Removed food giver
-Store now supports external descriptions
-Parkour now updates asyncronously
-New structure argument, "weight"
-New structure arguments, "place_marker", "remove_marker", "checkpoint" and "check_exit" (you can check Floating Fences to see them in action)
-Height control. The parkour will never hit the ground or the sky
-Exposed numberToDir and dirToNumber functions
-New block entry: disableAutobuild
Bomb Bloke #3
Posted 10 July 2015 - 04:32 PM
Well, I don't know if someone is even looking at this, but I have updated it.

B-but… Terraria 1.3!

Oh, all right.

This is actually very, very good. I liked Lion4ever's version, and you've improved upon it.

However, it still lacks a method for non-OPs to play it! Sure you can fire it up via the "monitor" script, but maybe consider rigging it so that if a monitor is attached, it will automatically allow that to be used to do everything except add/remove module files?

I've attempted to modify one of your modules into, well, something a little different. Not perfect, but it works well enough: pastebin get 8K0WVYvS ladder_swerve_jump.1

Though frankly I feel both it and the ladder jump module it's based on are a little punishing; they'd be a lot easier if they had an extra block tacked underneath them with another ladder segment. Left as-is, perhaps consider lowering the frequency of that module from appearing?
negamartin #4
Posted 11 July 2015 - 03:29 PM
Nice, you actually made something for this :D/> And it's fun!
I didn't make a non-OP method because this is strictly single-player, but with some scoreboard magic it could work on multiplayer (just only one player playing at the same time)
In that case, some code restructuring would have to be made. But it would be fun to do.
Yep, both structures are a little too difficult, but lowering the weight isn't the solution, but instead increasing the length, so the checkpoints are closer.
Do you mind if I upload your structure to the store? (with your name of course)
It will point to your pastebin (8K0WVYvS), so can you fix the weight and length please?
I'm sorry for stealing your Terraria time ;)/>
Bomb Bloke #5
Posted 12 July 2015 - 01:43 AM
I didn't make a non-OP method because this is strictly single-player, but with some scoreboard magic it could work on multiplayer (just only one player playing at the same time)
In that case, some code restructuring would have to be made. But it would be fun to do.

I'd recommend it, these sorts of things are much more interesting with multiple players.

If the script could record its block placements (which should be as simple as generating a unique randomisation seed for the session and storing that), it could even allow multiple players to run the exact same course.

Yep, both structures are a little too difficult, but lowering the weight isn't the solution, but instead increasing the length, so the checkpoints are closer.

But hang on, aren't the different module types supposed to be used in conjunction with each other? How does "length" work in that case?

Do you mind if I upload your structure to the store? (with your name of course)
It will point to your pastebin (8K0WVYvS), so can you fix the weight and length please?

Certainly you can use it; if you like, you can copy it into your own pastebin. I'm not too fussed about credit. ;)/>

I'm sorry for stealing your Terraria time ;)/>

's ok. I can't hit the stupid Queen Bee anyway. :(/> Maybe I need to buy a Minishark…
negamartin #6
Posted 13 July 2015 - 03:25 PM
Thanks! I have copied it into my own pastebin and put your name on it.

The lengths of each structure are added up, until a certain limit (depending on difficulty) is reached, and then a checkpoint is placed.
So, with 15 as length:
15 -> 30 -> 45 -> 60 -> 75 -> 90 -> 105(normal difficulty limit)
That is 7 ladder_swerves before the next checkpoint
With 30, there would be only 4.
And with other structures:
30(+30 ladder_swerve) -> 45(+15 floating_blocks) -> 75(+30 ladder_swerve) -> 90(+15 floating_blocks) -> 105(+15 floating_blocks)
Having a higher length means checkpoints will be closer.

For it to work in multiplayer in singleplayer mode would be easy. For it to truly work with multiple players, is hard.
How would it be? Players team up, or try to take each other down? Must all of them get to the end of the parkour to continue, or just 1?
However, for two players to race in the same parkour but in separate places, that would be a nice idea. But without randomseeds, since what if a structure uses os.time() or something got from the minecraft world to generate its blocks (heightWarp)? Then even having the same seed would lead to different blocks, and maybe even affect the whole parkour in front.
I think it's better to generate the parkour once and build it twice, once for every player.

I'm sorry for stealing your Terraria time ;)/>

's ok. I can't hit the stupid Queen Bee anyway. :(/> Maybe I need to buy a Minishark…
Well, I don't play Terraria and I don't think I can respond to that, so it's your decision (It always was, really. Why am I writing this?).
Bomb Bloke #7
Posted 14 July 2015 - 02:55 AM
The lengths of each structure are added up, until a certain limit (depending on difficulty) is reached, and then a checkpoint is placed.

Ah! That makes sense. A more difficult module therefore deserves a higher "length".

For it to work in multiplayer in singleplayer mode would be easy. For it to truly work with multiple players, is hard.
How would it be? Players team up, or try to take each other down? Must all of them get to the end of the parkour to continue, or just 1?
However, for two players to race in the same parkour but in separate places, that would be a nice idea. But without randomseeds, since what if a structure uses os.time() or something got from the minecraft world to generate its blocks (heightWarp)? Then even having the same seed would lead to different blocks, and maybe even affect the whole parkour in front.
I think it's better to generate the parkour once and build it twice, once for every player.

Certainly you wouldn't want multiple players running the same course at the same time; not unless there's a method available to prevent them from interfering with each other…?
negamartin #8
Posted 23 July 2015 - 06:02 PM
I have updated it (and the post, to look more beautiful), to V1.2 with multiplayer.
Changelog-Randomized starting direction.
-Now program doesn't close when parkour ends, and structure selection keeps.
-Now structures directory isn't placed at root.
-Fixed a bug when updating structures from the store.
-Fixed a bug where structure selection didn't keep.
-Limited no-starting time to 2 seconds max.
-Added "reference" block entry, similar to "disableAutobuild", but block isnt neither built or destroyed.
-Fixed a bug with scrolling.
-Multiplayer!
-Structures are generated once and deep-copied to all players.
-To skip deep-copy, set StructureTable.<somename>.global to true, where somename is a table you wish to be shared by all players.
-All players inside a "selection sphere" are selected to play.
-Different "gamemodes", freeplay, skill and race. Skill and Race are only available in multiplayer.
-Touchscreen monitor interface. Allows non-creative or non-OP players to access the parkour. Cant delete or download structures.
-To enable the monitor interface just connect an advanced monitor (atleast 2x2) to the computer. Monitors less than 2x2 will not be used.
-Item Confiscation. Items have to be deposited at a chest in the beggining, and recovered at the end.
-No ladder and stone column, instead a bedrock cage for your items and a single obsidian block.
-Added an optional config file. Format:
#Comment
parameter_name_with_underscores=14
other_boolean_parameter_name=true
Configs can't contain any spaces except after comments. Comments have to get a dedicated line.
-Config entries:
Spoilerplayer_selection_x=<number>
player_selection_y=<number>
player_selection_z=<number>
Specify absolute XYZ coordinates the player selection sphere to be centered on.
Defaults to computer coordinates.
player_selection_shift_x=<number>
player_selection_shift_y=<number>
player_selection_shift_z=<number>
Specify XYZ coordinates relative to the computer for the selection sphere.
All default to 0.
player_selection_range=<number>
Specify the radius of the selection sphere. Can be set to -1 for infinite range.
Defaults to 4.
always_allow_monitor_selection=<boolean>
Specify if monitors should always be able to select player and mode, even if game is started from the computer.
Defaults to false.
can_stay_in_creative=<boolean>
Specify if players can choose wether to keep their current gamemode, as long as the game is started from the computer.
Defaults to false.
allow_player_unlocking=<boolean>
Specify wether players can be unlocked from the monitor.
Defaults to true.
confiscate_items=<boolean>
Specify wether items should be stored in a chest or just cleared before starting the parkour.
Setting this value to false will display a warning saying that players' items will be destroyed.
Defaults to true.
-Disabled "stay-in-creative" mode by default, configurable. (see above)
-Added an automatic metadata system. By setting "autoMeta" to true in a block, the direction taken from the fifth entry will be changed into the correct metadata. See ladder_jump.1.1 for more info.
-Exposed new values, like "parkourGamemode()", "checkpointGoal()" and "playerCount()".
-De-exposed "transform()", since you now can't get the definitive position of a block in "build"ing state.

And I updated the structures too:
Spoiler-Updated to work with multiplayer
-Updated to use the new autometa system
-Updated archery_test, now target has to be cleared every time you die, and now target can be on both sides.
-ladder_swerve_jump(BombBloke) now doesn't drop ladders when deleting.
Edited on 23 July 2015 - 04:03 PM
Lion4ever #9
Posted 18 August 2015 - 12:22 PM
This is really cool.

Some tips: You can press f3 + s to make an invisible target visible (reload the chunks). Be careful to not walk down your platform.

Instead of letting the user put all their stuff in a chest, you could kill them above a hopper.
And if you break the chest they to pick up their stuff automatically, so if you break the chest ealier there is no need to burn the items in lava.

It would be really useful to download all (or multiple) jump parts at once in the download menu.

Some bugs:
-if i start the program without a monitor i get an "2222: attempt to index a boolean" error.
-when you check a checkpoint there is one block of the old part left (as a run-up, i guess) but you can not jump on the block sometimes because it is out of the areacheck
-if you have a fence and a 2 down ladder after that you get portet back on the fence sometimes, when you reach the ladder.

-i had so much bad luck that a archery target spawned behind an iron wall of the locked branch part.
Spoiler

Parts i made:

head_blocked.1.1
The jumps we all hate: Try to jump somewhere with a block over your head.
http://pastebin.com/s6qZLJrg

jump_around.1.1
There is a block in your way. Choose a side and jump a curve around it. All jumps are possible.
http://pastebin.com/Jqx5ks7E

This one is not quite safe yet, since the tnt falls to the ground when you reach a checkpoint…
booby_trap.1.1
Below the block you have to jump over is tnt, so better hurry up.
http://pastebin.com/zJm190rC
negamartin #10
Posted 19 August 2015 - 11:28 AM
-huge snip-

Thanks! I'm glad you liked it, and I hope you're not too angry that I copied your idea.
I didn't know about the F3+S shortcut, I will include it in the archery test's description. Thanks, I thought there was no way to fix it.
I think I unconciously(did I spell it right?) tried to avoid killing people, probably since xp is lost, and they can paralize the parkour by not pressing "Respawn", so I never really thought about it, but actually, I think that's a MUCH cleaner approach than forcing them to store their items, and I think the program can handle dead people without much modifications. But right now I'm into another project, and I dont feel like doing big reworks.
A "Download All" option, however, is pretty simple, and quite useful. I think I can do that right now.
Thanks for the suggestions!

Bugs:
-I had the monitor constantly attached during debugging, and I never actually checked what happened without a monitor. Thanks, I'll fix it.
-This one is sort of "intended". The last structure is conserved because without it you wouldnt have a place to stand on. There could be another type of call for this, but it would complicate more than what it fixes.
-Hmmm I thought I fixed all of that areaCheck bugs. I'll just increase the areaCheck.
-Wow. That is REALLY bad luck. If went back in the parkour, could you get somewhere you can shoot the target? Or was it really impossible to continue?

Cool! You made structures!
I'm on my phone right now, but as soon as I get to my computer I'll try them. I like the idea of a TNT boobytrap, though.
About the TNT falling, I'll see what can be implemented to allow fixing that. I'm not really sure what can be done.
I assume you posted these, apart from showing them, so that I can upload them. They will point to your pastebin, and have your name.

Thanks for trying it, it really makes me happy that someone tries it out.
Lion4ever #11
Posted 20 August 2015 - 03:21 PM
I hope you're not too angry that I copied your idea.
Not at all. You program is way more elaborated and better than mine :D/>

since xp is lost, and they can paralize the parkour by not pressing "Respawn", so I never really thought about it
You could testfor their xp level with something over complicated like this:

local lvl = 0
while not commands.testfor(string.format("@p[lm=%d,l=%d]",i,i)) do
lvl = lvl+1
end

A "Download All" option, however, is pretty simple, and quite useful. I think I can do that right now.
Nice :)/>

-Wow. That is REALLY bad luck. If went back in the parkour, could you get somewhere you can shoot the target? Or was it really impossible to continue?
It was directly after the obsidian marker and completly impossible. I had to switch to creative and fly a bit to the side.

About the TNT falling, I'll see what can be implemented to allow fixing that. I'm not really sure what can be done.
In the deleteStructure function you could add a struct.func("remove_structure",struct) call before deleting anything. Just like you did in the deleteCheckpoint function.

function deleteStructure(struct)
if not struct.func("remove_structure",struct) then
  for i,b in ipairs(struct.blocks) do
   if not b.reference then
    commands.async.setblock(b[1],b[2],b[3],"minecraft:air 0 replace");
    if i%200==0 then sleep(0.05); end
   end
  end
end
end

I assume you posted these, apart from showing them, so that I can upload them. They will point to your pastebin, and have your name.
Feel free to add them to your pastebin and modify them, if you state me as author or co-autor of these :)/>
negamartin #12
Posted 13 September 2015 - 05:43 PM
After some (unnecessary long) time, I have updated it to V1.21, with some small fixes.
Changelog-Fixed error when playing without monitor
-Added "Download All" button
-Installed structures can be checked and re-downloaded
-Added "place_structure" and "remove_structure" events. If they return true, structure wont be destroyed or built. Currently unused
biggest yikes #13
Posted 13 September 2015 - 06:37 PM
I'm going to be honest here:
Wait, did you expect a rebuke on how terrible this program is? No, no no!
This thing is awesome!
I haven't even tested it yet, and I can already tell how useful this tool might be for servers (assuming, of course, it was modified to support multiple players). They could have parkour races that aren't even built by hand, so you never know what's going to happen each session!
Keep up the good work!

EDIT: After testing this, I have concluded that extreme effort has been put into this creation and it is AWESOME.
A suggestion: Perhaps make a program that lets us place a structure, "scan" it, ask us for input for weight, length, etc., then turn it into a file.
Also, a bug: The exploding TNT structure doesn't regenerate it's TNT if the structure is the checkpoint one.
I dropped my pocket computer in the world and I had to delete my world ;-;
Edited on 13 September 2015 - 04:57 PM
negamartin #14
Posted 14 September 2015 - 09:37 PM
Wow, thanks! :D/>
I'm glad you like it!

Yes, I made this with server use in mind, but I guess that scoreboard kinda ruins the 'multiple players' thing, since everyone sees the scoreboard if one person is playing.

That's a good idea! I never even thought of something like that, but it would be truly useful.
However, there are some limitations, getBlockInfo doesn't return NBT, so chests filled with stuff or command blocks would not be copied, and of course, scanned structures would be less random and functional that coded ones. However, structures made with the "structure maker" could be just used as a base, and then coded on top. It's a very good idea.

The TNT not regenerating is not a bug, it's the way it works. When you reach a checkpoint, all previous structures, except the last one, which has the checkpoint, are deleted, but the last one is no longer updated. It is not deleted just for you to have a place to stand on.

Well, you didn't have to delete your world, you would just have to quit it and relog. The parkour currently does not reload. You would have to break the blocks by hand, but atleast you wouldn't be trapped there :P/>. Didn't know that could happen, but I was thinking of automatic item clearing when you die, which would solve that issue.

Anyways, I'm really glad you liked it!