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

MiniatureCraft [New Version, 1.2]

Started by Antelux, 02 July 2014 - 02:51 PM
Antelux #1
Posted 02 July 2014 - 04:51 PM
Well, not sure if many of you remember that old post I made about this game, but I thought its about time to release it. I left it alone for awhile to work on my upcoming OS, however, I bring you what some of you may have been waiting for!

MiniatureCraft!


Current Version: 1.2

As of now, there's a buffer in the game to reduce flickering. However, it will be needing some improvements, so expect to see them as the game updates. Here's some basic info:

Key Features:
* Loading / Saving your worlds.
* Survival / Creative Modes.
* A (Unused) Time System.
* Crafting / Smelting.
* A Variety of Blocks and Items.
* Options menu for tweaking your character, or the game in general.
* The ability to add and name servers to join. (Server script is not completed).
* Inventory Management.
* (Finite) Randomly generated worlds, which can be made from 64x64 to 256x256 when creating your world.
* Pick up and play controls.
* Modding.


Controls: (Default, only changeable via editing code)
W or Arrow Key Up: Up
A or Arrow Key Left: Left
S or Arrow Key Down: Down
D or Arrow Key Right: Right

E: Interacts with the block your facing. If there isn't a block, then it opens your inventory.
Shift: Keeps character from switching direction when moving.
Space: Uses the currently equipped item on the block / tile directly in front of you.
Backspace: Enters the Pause menu.

F2: Changes gamemode. (Temp)
F3: Shows / Hides Debug info.
F4: Changes your dimension. (For now, you can only switch between overworld and caves, also temp)
F5: Saves world.

Controls in menus: (Default, only changeable via editing code)
W or Arrow Key Up: Move to upper selection.
A or Arrow Key Left: Move to left selection.
S or Arrow Key Down: Move to lower selection.
D or Arrow Key Right: Move to right selection.

Enter: Chooses the currently selected item.
Backspace: Goes back to the menu you were last in.

There are clickable buttons, usually found at the bottom of the menu, shown in its own border.
Gray boxes are for text input. Click them to enter text as you normally would.

Creative Info:
When in creative, your inventory wont change when using items / blocks. You can also craft for free this way.
Also, left clicking on the mouse anywhere in the world places a block. Right clicking removes blocks. Scroll to change blocks. To see the different blocks, look at the debug info (F3).

Install:
To install MiniatureCraft, go into shell and run: pastebin run g2ijEJ3S

Known bugs:
* When using a item, the durability bar doesn't change / both numbers decrease.
* When placing items in a "hole" tile, sometimes you need to place it at a specific direction.
* Sometimes, when making a new world, it will error with "Too long without yielding". This is because the generation code does alot, going over the world multiple times. Its recommended you use 64x64 worlds - Fixed, Thanks to TheOddByte.

Version List:
Current version: 1.2 (The Menu Update)
* Added in a multiplayer menu where you can add and name servers. This will be used for when the server script is ready.
* Added in a options menu. Here, you can change the player name and color, aswell as change the type ingame drawing.
* Added in a Exit option for quitting the game.
* Single player worlds can now be loaded from a menu, and created from the same one.
* A pause menu ingame (Backspace to get into)
* Better stability.

Old Versions:
Spoiler1.1b: Initial Release.
1.1c: Buffer implemented. slightly better game play, but is rather slow. Buffer speed ups coming in 1.1d.

Upcoming Features: (In random order)
* The ability to load saves. (The function to load worlds is already made and working, but I just need to make it save Inventory's as well) Done in 1.2.
* A buffer to make the game run smoother. A faster and more efficient buffer.
* Better game mechanics (Farming, lighting, etc)
* Multiplayer! :D/>
* Better Pocket Computer support.

Modding: (Yes, modding.)
For all of you interested in making mods for MiniatureCraft, here's a quick tutorial.

First, we make a file. In this case, I'll name my file "SapphireMod".
We need to add our own assets in the game, so we create a table. Now, lets make out first block.

The index of the table should be the ID of your item. So, for example, a block that has a ID of 30 should look like this:
Spoilerlocal moddedAssets = {
[30] = {}
}

Now, we cant have a empty table as a block. This is what each block / tile has to have in its asset.
Spoilername = string – Self explanatory
health = number– How many times a block can be hit before it breaks. As a reference, wood tools do a max damage of 1, while gem tools do a max damage of 5.
drop = table – The drop is what the block drops when broken. The table format must be {id, amount, id, amount, …}
type = string – The type of block it is. If its meant for pickaxes, the type is "rock". If its meant for axes, the type is "wood". If it doesn't really matter what breaks it, the type is "any".
bgT = number (color) – The background color of the block / tile. For example, the background color for grass is colors.lime.
fgT = number (color) – The foreground color of the block / tile. For example, the foreground color for grass is colors.green.
fgS = string – This is the "character" that goes on top of the block / tile. This uses the fgT color. For example, the fgS of grass is ">". The fgS is recommendedto be one character.

Now, after putting the necessary values, we should have something like this:
Spoilerlocal moddedAssets = {
[30] = {name = "Sapphire Ore", health = 25, drop = {230, 1}, type = "rock", bgT = colors.lightGray, fgT = colors.blue, fgS = "+"}
}

After we are done with our table, for the game to use it, we simply put:
LoadAPI.addMod(string (name of type of stuff your adding), string (type), table (The stuff you plan to add in), string (info, nice to have, but not necessary) )

So, after we have put all the values needed, the function should look similar to this:
LoadAPI.addMod("SapphireBlocksAndItems", "asset", moddedAssets, "Sets the data for sapphire stuff.")

And the final code:
Spoilerlocal moddedAssets = {
[30] = {name = "Sapphire Ore", health = 25, drop = {230, 1}, type = "rock", bgT = colors.lightGray, fgT = colors.blue, fgS = "+"}
}

LoadAPI.addMod("SapphireBlocksAndItems", "asset", moddedAssets, "Sets the data for sapphire stuff.")

I'll get more into modding the game later, but for now, this should serve as a template for modding. Its basically a follow up to the whole "SapphireMod" things.

And one last thing about modding! To use the mods in-game, drop your mods into the folder (Your MiniatureCraft Directory)/MiniMods. For example, if the game installed to a folder named "game", you would put your mods in the folder "game/MiniMods". More on modding will be added later.

After your done with your mods, pm them to me with some basic info on it, and I'll add it to the post for others to use. Your mods must be compatible with vanilla MiniatureCraft, not your own modified version.

Notice about asset IDs: MiniatureCraft reserves the IDs 1 - 500. Please keep your asset IDs from 501 - 1000 as that's the limit. I have not stopped mod files from overwriting the vanilla assets, but please don't do so unless your mod changes the asset to be compatible with your mod.

License:
This game is under the Creative Commons Attribution-NonCommercial 4.0 International Public License. Click on the link for more info on the license.

Note: Lots of the game is not optimized, however, you can expect slight speed ups throughout updates.

Latest News: The game's buffer has been improved, causing drastic speed-ups, especially for Pocket Computers. The game is even more playable now! The server script is being worked on, but the next update will most likely include the ability to load worlds, chatting, and a multiplayer option for when the server script is ready. -7/17/14 Em working on better Pocket computer support, and will be looking into a better buffer to make the game more enjoyable. -7/2314
Edited on 24 July 2014 - 11:28 PM
Saldor010 #2
Posted 02 July 2014 - 05:48 PM
Very laggy and jittery, though this is the first release, so we can't expect it to be fully optimized. I'll try this later on an emulator and see if it runs any better.
TheOddByte #3
Posted 02 July 2014 - 08:56 PM
Haven't really tried this yet( since I'm on my phone right now) but this seems awesome! As soon as I've started my computer I'll try it and post some feedback for you
Antelux #4
Posted 02 July 2014 - 09:27 PM
Very laggy and jittery, though this is the first release, so we can't expect it to be fully optimized. I'll try this later on an emulator and see if it runs any better.

Yep, it could really use some tweaking.

Haven't really tried this yet( since I'm on my phone right now) but this seems awesome! As soon as I've started my computer I'll try it and post some feedback for you

Sounds good! Hopefully this game gets popular. Though, I'm most excited to see people make mods for it.
TheOddByte #5
Posted 02 July 2014 - 09:31 PM
Sounds good! Hopefully this game gets popular. Though, I'm most excited to see people make mods for it.
Yeah I'm interested in the modding part, it's very unusual for ComputerCraft games :P/>
Are you planning on creating online multiplayer for this sometime in the future?
Edit: I just tried it out, And to be honest it's very slow at the moment and is very flickery, but I can't complain since this is the first release.
I have a bug to report though or what you want to call it

FileAPI:89: Too long without yielding
this occured when I tried starting a new world
Edited on 02 July 2014 - 07:48 PM
Antelux #6
Posted 02 July 2014 - 09:48 PM
I'm not sure, but I do plan on creating a server script so at least people can play in-game together. In the mean time, Ill be working on game mechanics and speeding it up and general. A script for online gaming is a bit far, but its doable :)/> If anyone plans to make mods, ill gladly add it to the thread for others to use.
TheOddByte #7
Posted 02 July 2014 - 09:55 PM
I'm not sure, but I do plan on creating a server script so at least people can play in-game together. In the mean time, Ill be working on game mechanics and speeding it up and general. A script for online gaming is a bit far, but its doable :)/> If anyone plans to make mods, ill gladly add it to the thread for others to use.
Well I might create some mod when this gets a buffer and is faster than it currently is :P/>
Antelux #8
Posted 02 July 2014 - 10:01 PM
I have a bug to report though or what you want to call it

FileAPI:89: Too long without yielding
this occured when I tried starting a new world

Yea, the world generator can be very stressful sometimes. The game deals with alot of tables, so for now, its recommended you make 64x64 worlds. I'll add this to the bug list.

Well I might create some mod when this gets a buffer and is faster than it currently is :P/>

Sounds good! When I create a server script, I plan to make the client automatically download any mods. Now, if you get bored of the game, you can make your own content :P/>
TheOddByte #9
Posted 02 July 2014 - 10:01 PM
I have a bug to report though or what you want to call it

FileAPI:89: Too long without yielding
this occured when I tried starting a new world

Yea, the world generator can be very stressful sometimes. The game deals with alot of tables, so for now, its recommended you make 64x64 worlds. I'll add this to the bug list.
Well here's a way to fix it :P/>

local function yield()
    os.queueEvent("sleep")
    os.pullEvent("sleep")
end
I guess this error occurs in a loop, so all you would have todo would be to let it yield for a small amount of time. This is much faster than sleep
Antelux #10
Posted 02 July 2014 - 10:02 PM
Well here's a way to fix it :P/>

local function yield()
	os.queueEvent("sleep")
	os.pullEvent("sleep")
end
I guess this error occurs in a loop, so all you would have todo would be to let it yield for a small amount of time. This is much faster than sleep

Thanks. Ill try that.
Antelux #11
Posted 02 July 2014 - 10:18 PM
Just posted a fix for world creation (Thanks TheOddByte). Now, you should be able to do any world type (64x64 - 256x256). Though, the worlds do take slightly longer to be created. (Especially the 256x256 ones)
cptdeath58 #12
Posted 02 July 2014 - 10:27 PM
This… Is… Awesome…
Geforce Fan #13
Posted 02 July 2014 - 10:39 PM
I'd recommend you write the entire world to a buffer then just make changes to it. Don't write the character to a buffer though; instead just have him stay in one place while the entire world moves.
cptdeath58 #14
Posted 02 July 2014 - 10:48 PM
I'd recommend you write the entire world to a buffer then just make changes to it. Don't write the character to a buffer though; instead just have him stay in one place while the entire world moves.
But what about him moving in a different direction….
cptdeath58 #15
Posted 02 July 2014 - 11:08 PM
Glitch Found: After saving, your character does not change direction during movement.
Only after saving twice does it get fixed.
Also happens when you try to go over the edge of the screen. (I "lagged")
Also when changing dimensions.
Edited on 02 July 2014 - 09:19 PM
cptdeath58 #16
Posted 02 July 2014 - 11:18 PM
Is there a way to exit the game without Ctrl + T?
Antelux #17
Posted 02 July 2014 - 11:55 PM
Glitch Found: After saving, your character does not change direction during movement.
Only after saving twice does it get fixed.
Also happens when you try to go over the edge of the screen. (I "lagged")
Also when changing dimensions.

I'll look into these.

Is there a way to exit the game without Ctrl + T?

No, not at the moment. I actually recommend you restart the whole system when exiting the game, because I get some weird errors if I do stuff after doing a Cntrl + T. Once I make better menus and such, you'll be able to though.
Edited on 02 July 2014 - 09:55 PM
Antelux #18
Posted 03 July 2014 - 12:35 AM
For now on, if anyone has bugs to report, please make sure the bug is repeatable, and perhaps state the process in which you made it happen.
Edited on 02 July 2014 - 10:35 PM
Antelux #19
Posted 03 July 2014 - 12:40 AM
Glitch Found: After saving, your character does not change direction during movement.
Only after saving twice does it get fixed.
Also happens when you try to go over the edge of the screen. (I "lagged")
Also when changing dimensions.

I couldn't reproduce this glitch. Make sure you didn't press Shift anytime there. Shift keeps your direction the same regardless of movement.
cptdeath58 #20
Posted 03 July 2014 - 01:43 AM
Maybe the problem. I may had held shift on accident.
Csstform #21
Posted 03 July 2014 - 03:28 PM
I get some weird errors if I do stuff after doing a Cntrl + T.

I would assume this is due to the use of global variables. All in all tho, this looms like a cool idea, especially the mods and such.
Antelux #22
Posted 03 July 2014 - 05:06 PM
I get some weird errors if I do stuff after doing a Cntrl + T.

I would assume this is due to the use of global variables. All in all tho, this looms like a cool idea, especially the mods and such.

Yea, I figured as much. Hopefully I can get proper exiting in soon. I've already implemented a buffer so far, except not everything on the screen draws. Currently fixing though, and soon enough the game will be playable! (In terms of lag / flickering.)
TheOddByte #23
Posted 03 July 2014 - 08:51 PM
Yea, I figured as much. Hopefully I can get proper exiting in soon. I've already implemented a buffer so far, except not everything on the screen draws. Currently fixing though, and soon enough the game will be playable! (In terms of lag / flickering.)
If you're looking for a way to exit a program then try error

local function exit()
    term.clear()
    term.setCursorPos( 1, 1 )
    print("Thanks for playing!")
    error()
end
This is just a simple example, but it should work ;)/>
Antelux #24
Posted 03 July 2014 - 09:02 PM
Yea, I figured as much. Hopefully I can get proper exiting in soon. I've already implemented a buffer so far, except not everything on the screen draws. Currently fixing though, and soon enough the game will be playable! (In terms of lag / flickering.)
If you're looking for a way to exit a program then try error

local function exit()
	term.clear()
	term.setCursorPos( 1, 1 )
	print("Thanks for playing!")
	error()
end
This is just a simple example, but it should work ;)/>

Don't worry, I already have some code in mind. I'm not bad at programming, just lazy :P/>
TheOddByte #25
Posted 03 July 2014 - 09:09 PM
Don't worry, I already have some code in mind. I'm not bad at programming, just lazy :P/>
Haha okay, But that's usually the best way to exit a program :P/> ( IMO )
Antelux #26
Posted 18 July 2014 - 01:53 AM
Made the buffer run (alot) faster, the game should be more stable now. More details in the main post.
Saldor010 #27
Posted 18 July 2014 - 02:18 AM
Still very laggy for me, but I'm sure it will get better over time. Atleast it's playable now ;)/>
Antelux #28
Posted 23 July 2014 - 05:11 PM
Update 1.2. Is out, with a bunch of new…. menus! More info in the main post.
TheOddByte #29
Posted 23 July 2014 - 09:34 PM
Does the game run faster in the new version? I see that it's atleast playable now( from the comment above yours )
And how far from completion is the server script?
Antelux #30
Posted 24 July 2014 - 01:31 AM
Its… getting there. I cant actually send the map over rednet, because it contains recursive entries. However, I found a solution that may stop users from having to download anything server related, like custom assets and such. This would probably increase security. As for the games speed, I have been having some problems with the buffer. I've tried to implement a feature to only draw what changes on the screen, and it hasn't gone too well.
Edited on 23 July 2014 - 11:32 PM
TheOddByte #31
Posted 24 July 2014 - 10:51 PM
Its… getting there. I cant actually send the map over rednet, because it contains recursive entries. However, I found a solution that may stop users from having to download anything server related, like custom assets and such. This would probably increase security. As for the games speed, I have been having some problems with the buffer. I've tried to implement a feature to only draw what changes on the screen, and it hasn't gone too well.
I hope you're having the buffer as the top priority right now, because having the game running smooth before doing multiplayer is better :P/>
Antelux #32
Posted 25 July 2014 - 01:05 AM
I hope you're having the buffer as the top priority right now, because having the game running smooth before doing multiplayer is better :P/>
Yea, I agree. I'm looking into faster methods. Of course, there are other ways to make faster buffers, but I specifically want mine to be a redirect one. It simplifys alot of things. Hopefully I can get the buffer to draw the changes only sometime soon. It can be a real turnoff for others if they cant play decently.
YoYoYonnY #33
Posted 11 October 2014 - 09:03 PM
I think the APIs are a bit of a overkill. They might slow your game down and they might delay the rendering. At the very least, you should use a rendering method in the main game program, like this:

for x=1,w do
  for y=1,h do
    term.setCursorPos(x,y)
    term.setBackgroundColor(map[x][y].bc)
    term.setTextColor(map[x][y].tc)
    term.write(map[x][y].char)
  end
end
TheOddByte #34
Posted 12 October 2014 - 05:16 PM
The problem with that code is that it would flicker alot without at proper buffer.
YoYoYonnY #35
Posted 16 October 2014 - 11:32 PM
The problem with that code is that it would flicker alot without at proper buffer.
Thats why I posted this exact code. It doesnt have the term.clear(), so the screen wont flicker. Acturely, if you redraw the same stuff you did before, you wont even notice the redraw.
Edit: I just made a term.redraw() function to redraw the screen only when I need to

for n=0,15 do
    term.setBackgroundColor(2^n)
    term.clear()
    term.redraw()
    -- Flicker the screen with all the different colors
end
for n=0,15 do
    term.setBackgroundColor(2^n)
    term.clear()
end
term.redraw()
-- Make the screen black (No flickering)
Edited on 16 October 2014 - 09:35 PM
CoLDarkness #36
Posted 17 October 2014 - 06:52 PM
Great work. Really interesting.
AssossaGPB #37
Posted 17 October 2014 - 07:12 PM
Nice Smith, can't believe how complex that is :D/>
Saldor010 #38
Posted 17 October 2014 - 08:10 PM
Decided to check this game again, and see if it was any better when it came to lag.
..
IT IS!

It's about 3 times better than it was when it first released, and is now actually playable for people like me who do vanilla Computercraft!

Awesome job man!
Antelux #39
Posted 17 October 2014 - 08:39 PM
Hmm. Didn't know this thread was still alive. Might as well tell you whats with it so far.

Basically, I did finish up a "working" buffer than only uses strings instead of tables, making it less of a memory hog, and allows for better rednet compatibility. I stopped awhile ago on the progress, but I don't remember why.

I might restart working on the game again. If I do, ill most likely rewrite it from the ground up, because I'm like that :P/>
Though, I would use some of the API's already available. It would mostly just be for cleaner code. Anyway, its cool to see people still playing my game, so thanks!
Antelux #40
Posted 21 December 2014 - 09:54 PM
Guess what. MiniatureCraft isn't dead.

MiniatureCraft 2.0