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

Selection menu for a Construction program

Started by flaunting, 21 April 2016 - 05:34 PM
flaunting #1
Posted 21 April 2016 - 07:34 PM
Hi there,

I am starting a new construction program and have a couple of queries.

The first is that I plan to have several structures as options for the user. what would be the best way to choose which structure to build within the opening menu.

My second question is about best practice.
Is it better to have the programming for each structure as functions within one program or would it be better to have several programs which get called by the main program.
Lyqyd #2
Posted 21 April 2016 - 07:39 PM
The system I used in my project builder program is to have one program provide the interface and to use separate files for each project to specify its requirements and instructions.
flaunting #3
Posted 21 April 2016 - 08:10 PM
If I were to use that method what would be the best way to compile these files so I can provide a simple installation, the program I am making is to have a turtle build the various complicated immersive engineering multi lock structures which I think there are around 10.

Also which is the best ui method to display the options

Also I am new to programming so wish to keep code less complicated if possible. I have done the code for the building just trying to figure out the interface
Edited on 21 April 2016 - 06:12 PM
Bomb Bloke #4
Posted 22 April 2016 - 12:57 AM
It sorta depends whether you expect users to use your construction files, whether you expect them to be building their own, and how often you expect to be editing it all after release.

For example, with WorldPorter (a script for OPs, which copy/pastes structures directly using Minecraft server commands), I provide the main code via a single pastebin download, and separate to that, a number of demo structures combined together using Package. There are a number of other scripts around for handling distribution of multiple files, eg Packman, Grin-Get

If you always want to distribute all your files together, you might put each into a separate paste, and have the main script file download all the others the first time you run it:

if not fs.exists("addonScript1") then shell.run("pastebin get <pasteID> addonScript1") end
if not fs.exists("addonScript2") then shell.run("pastebin get <pasteID> addonScript2") end
etc...

This way, you don't have to rebuild a combined archive every time you want to edit one of the extra script files. It's generally how I distribute any projects which need to have certain extra files.
flaunting #5
Posted 22 April 2016 - 07:36 AM
Ok that's sounds great, although I shouldn't have to update the files but I will need to release a second version dedicated to 1.8.9 immersive engineering as it has different multi blocks.

Is there an api or a simple program that can get me started on the ui script as I have not written one before?

Or have you got any tips
Lupus590 #6
Posted 22 April 2016 - 09:54 AM
search the forums for a GUI API

I usually find google gets better results than the built-in search, just make sure that google is searching the forums (add "site:computercraft.info" to your search)
KingofGamesYami #7
Posted 22 April 2016 - 03:07 PM
I made this, which does everything for you. Pro: Does everything. Con: hard to modify.

[/shamelesspromotion]
flaunting #8
Posted 22 April 2016 - 03:56 PM
sorry about my noobyness but can I run that as an API or just put it at the top of my code
flaunting #9
Posted 22 April 2016 - 05:02 PM
I made this, which does everything for you. Pro: Does everything. Con: hard to modify.

[/shamelesspromotion]

So I have attempted to implement this but when I run my attempt I get an eof error


bios.lua:14: [string "tempMenu"]:137:'<eof>' expected

my full code here

What am I doing wrong?
KingofGamesYami #10
Posted 22 April 2016 - 05:27 PM
sorry about my noobyness but can I run that as an API or just put it at the top of my code

Whichever makes you happier!

What am I doing wrong?

You don't need to 'end' your if statement until you've used all your 'elseifs'. Eg:


if (something) then

elseif (something else) then

else

end
flaunting #11
Posted 22 April 2016 - 10:17 PM
Thanks everyone for your help, I got the menu working now, again sorry for being a bit slow