Jump to content




How to use Bedrock (Bedrock Documentation)


  • You cannot reply to this topic
83 replies to this topic

#1 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 20 July 2014 - 02:21 AM

If you haven't already, read the post that briefly explains what Bedrock is. This is essentially the documentation.

Just a warning that this is a very, very, very large tutorial. In fact it's turned in to a 6,300 word, 17 paged monstrosity. It's designed to teach you Bedrock from the ground up and there are tons of things to cover. I highly recommend you do the first few spoilers. Some of the latter ones are things that not everyone needs to know or you might not need to know right now. Once you've got the basic idea you can simple pick the ones you want to read. I wouldn't skim read the first sections, they contain a lot of information about how Bedrock works, which is vital to understanding how to make your programs.

I haven't quite covered everything yet, I haven't be able to write some really advanced topics (custom objects, custom windows, scroll views, etc) due to time constraints. But I will add them soon. Some of the spoilers didn't want to do what they were supposed to either, so some formatting is a little off.

Getting Started

Views (Basics)

Buttons, Labels and Other Basics

Getting and Setting Values With Code

Object Events (Clicking Buttons)

Alert Windows

Timers

Custom Event Handling
Spoiler

Add and Removing Objects (Using Code)
Spoiler

Menus
Spoiler

Text Boxes

Image View
Spoiler


Thanks for trying out Bedrock. It might take a bit of getting used to, but I think you'll find it very useful. As mentioned at the top, I haven't quite finished, but those tutorials will come soon.

At this stage Bedrock is in beta. I'll try to avoid future updates that break things, but I don't really see myself changing much really. Bedrock is a culmination of PearOS, OneOS 1-1.1 and my work in Cocoa. It's pretty much my ultimate GUI API.

Anyway, please give any feedback about Bedrock itself on the topic in APIs & Utilities. This topic is strictly for tutorials/documentation.

A final reminder. I ask that if you have any issues you just can't solve you either post here, or if it's a large problem create an Ask a Pro topic. It's probably also a good idea to PM me with a link to the topic, as I don't really look in Ask a Pro very much and mightn't see it. It just makes the answers public and easy to find.

Enjoy!

Edited by oeed, 29 April 2016 - 09:05 AM.


#2 Win7yes

  • Members
  • 110 posts

Posted 20 July 2014 - 07:00 AM

This is like... A GUI programming language xD
Looks very nice, I will use it for something tomorrow

Found out by reading that that this comment doesn't go here :P

Edited by Win7yes, 20 July 2014 - 08:56 AM.


#3 Awesomesause200

  • Members
  • 18 posts

Posted 20 July 2014 - 04:09 PM

This sounds like an amazing idea, I like it. However, I must be a pretty big noob, but I cannot seem to get the bedrock to start a program

I managed to get up to this far into the tutorial and then I get stumped:

local bedrockPath='/'
if OneOS then OneOS.LoadAPI('/System/API/Bedrock.lua', false)
elseif fs.exists(bedrockPath..'/Bedrock')then 
os.loadAPI(bedrockPath..'/Bedrock')else if http then print('Downloading Bedrock...')
local h=http.get('http://pastebin.com/raw.php?i=0MgKNqpN')
if h then 
local f=fs.open(bedrockPath..'/Bedrock','w')
f.write(h.readAll())
f.close()
h.close()
os.loadAPI(bedrockPath..'/Bedrock')
else error('Failed to download Bedrock. Is your internet working?') end 
else error('This program needs to download Bedrock to work. Please enable HTTP.') 
end 
end 
if Bedrock then 
Bedrock.BasePath = bedrockPath 
Bedrock.ProgramPath = shell.getRunningProgram() 
end


local program = Bedrock:Initialise()

program:Run(function()
program:GetObject('HelloLabel').Text = 'That was easy!'
program:GetObject('HelloLabel').BackgroundColour = colours.lightBlue
end)

Am I missing something here?

#4 Win7yes

  • Members
  • 110 posts

Posted 20 July 2014 - 04:35 PM

Do you get an error or nothing on screen appears?

#5 Awesomesause200

  • Members
  • 18 posts

Posted 20 July 2014 - 08:33 PM

I got an error screen saying: "bedrock:2178: attempt to index ? (a nil value)"

Edit: Forgot to add the code for the Views/main.view program, I'll add it now

Spoiler

Edited by Awesomesause200, 20 July 2014 - 08:37 PM.


#6 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 20 July 2014 - 09:57 PM

View PostAwesomesause200, on 20 July 2014 - 08:33 PM, said:

I got an error screen saying: "bedrock:2178: attempt to index ? (a nil value)"

Edit: Forgot to add the code for the Views/main.view program, I'll add it now

Spoiler
I'll change that to a better error message.

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 July 2014 - 12:31 AM

I feel like I've read somewhere that you have a wiki, yes?

#8 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 21 July 2014 - 01:10 AM

View Posttheoriginalbit, on 21 July 2014 - 12:31 AM, said:

I feel like I've read somewhere that you have a wiki, yes?

You probably have. Not yet, but I'm thinking of putting more of a description of what each function does and leave this for a more detailed tutorial.

#9 thijsmie

  • New Members
  • 1 posts

Posted 21 July 2014 - 01:32 PM

I believe there is a bug: the variable ProgramPath includes the name of the actual file, so if I have a program startup, it tries to load views from /startup/Views instead of /Views.

#10 Win7yes

  • Members
  • 110 posts

Posted 21 July 2014 - 06:17 PM

Bug: I did the basic view thing, running under OneOS, and then when I ran the application, it said
AppRedirect.lua:143: attemp to compare number with string expected, got number
If I remove the BackgroundColour='white' line it will run fine, but background is transparent.
Edit: Code of both, the main.view file and the program's main file
Main File (startup)
Spoiler
View File:
Spoiler
Edit 2: Apparently is an OneOS and the AppRedirect.lua file related issue. What does the AppRedirect.lua file do?

Edited by Win7yes, 21 July 2014 - 09:56 PM.


#11 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 21 July 2014 - 09:54 PM

View PostWin7yes, on 21 July 2014 - 06:17 PM, said:

Bug: I did the basic view thing, running under OneOS, and then when I ran the application, it said
AppRedirect.lua:143: attemp to compare number with string expected, got number
If I remove the BackgroundColour='white' line it will run fine, but background is transparent.
Edit: Code of both, the main.view file and the program's main file
Main File (startup)
Spoiler
View File:
Spoiler
Edit 2: Apparently is an OneOS issue and the AppRedirect.lua file used to I pressume redirect applications to the program tabs
OneOS actually has a different (out of date) version of Bedrock. I'll update it later this week. For now just use it standalone.

#12 Win7yes

  • Members
  • 110 posts

Posted 21 July 2014 - 10:08 PM

Question Time!
How can I make a box with a scrollbar and put text in it?
Or a better question:
How do ScrollViews work?

Edited by Win7yes, 22 July 2014 - 12:13 AM.


#13 Win7yes

  • Members
  • 110 posts

Posted 22 July 2014 - 02:16 AM

View Postoeed, on 21 July 2014 - 03:02 AM, said:

View PostWin7yes, on 21 July 2014 - 02:46 AM, said:

No but I mean I left some things that made the program:Quit() fail to close and it just closed the Alert box. And Sorry :P I will make help posts in the tutorial
topic in the future

Oh I see, can you give some example code? (post in the tut. topic)
program:DisplayAlertWindow("Message", "Hello", {"Ok"}, function(value)
  if value == "Ok" then
    if program:Window then
	  program.Window:Close()
    end
  end
end)
Then I replaced the program.Window:Close() with program:Quit(). Code ended like this:
program:DisplayAlertWindow("Message", "Hello", {"Ok"}, function(value)
  if value == "Ok" then
    if program:Window then
	  program:Quit()
    end
  end
end)
Resulting in it not quiting the program because of an unknown reason. It would just close the alert window
PS: I reply just now because I saw your post on the APIs and Utilities section just now :P

#14 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 22 July 2014 - 09:52 PM

View PostWin7yes, on 21 July 2014 - 10:08 PM, said:

Question Time!
How can I make a box with a scrollbar and put text in it?
Or a better question:
How do ScrollViews work?
Sorry for not replying sooner, I've been very busy with homework.
When I find the time I'll add a section about scroll views, for now take a look at the code for ListView and CollectionView. They do require you to make your own object, but it's not too hard. Make a folder called 'Objects' and create a file named something like "TextView.lua" and copy the code from one of those in to it.

View PostWin7yes, on 22 July 2014 - 02:16 AM, said:

View Postoeed, on 21 July 2014 - 03:02 AM, said:

View PostWin7yes, on 21 July 2014 - 02:46 AM, said:

No but I mean I left some things that made the program:Quit() fail to close and it just closed the Alert box. And Sorry :P I will make help posts in the tutorial
topic in the future

Oh I see, can you give some example code? (post in the tut. topic)
program:DisplayAlertWindow("Message", "Hello", {"Ok"}, function(value)
  if value == "Ok" then
	if program:Window then
	  program.Window:Close()
	end
  end
end)
Then I replaced the program.Window:Close() with program:Quit(). Code ended like this:
program:DisplayAlertWindow("Message", "Hello", {"Ok"}, function(value)
  if value == "Ok" then
	if program:Window then
	  program:Quit()
	end
  end
end)
Resulting in it not quiting the program because of an unknown reason. It would just close the alert window
PS: I reply just now because I saw your post on the APIs and Utilities section just now :P
When the function for an alert window is called the window has already closed, so it doesn't exist. However, you know that at some point there was one. Change it to something like this:
program:DisplayAlertWindow("Message", "Hello", {"Ok"}, function(value)
  if value == "Ok" then
    program:Quit()
  end
end)


#15 Win7yes

  • Members
  • 110 posts

Posted 22 July 2014 - 09:56 PM

I did change the code and it worked.

#16 Lua.is.the.best

  • Members
  • 76 posts

Posted 30 July 2014 - 02:27 AM

I found a error in the text.

Quote

In the future I hope to make a program which allows you do make views using a drop and drop interface

Edit: Misspelled (to) too, italicized it

Seems like this goes in a PM. xD

Edited by Lua.is.the.best, 30 July 2014 - 02:30 AM.


#17 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 13 September 2014 - 01:54 AM

It's great that I can load a view, but how do I unload a view?

#18 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 13 September 2014 - 05:07 AM

View PostJiloacom, on 13 September 2014 - 01:54 AM, said:

It's great that I can load a view, but how do I unload a view?

Well, you should be able to just load another. That should work. Why would you want to?

#19 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 13 September 2014 - 02:42 PM

View Postoeed, on 13 September 2014 - 05:07 AM, said:

View PostJiloacom, on 13 September 2014 - 01:54 AM, said:

It's great that I can load a view, but how do I unload a view?

Well, you should be able to just load another. That should work. Why would you want to?

I was going to use different views for different scenes of my program, but I don't need to anymore, I was able to find a work around.

#20 AssossaGPB

  • Members
  • 126 posts
  • LocationFlorida, USA

Posted 12 October 2014 - 06:33 PM

I have my files set up just like yours from the first two spoilers, but it claims I need to call LoadView(). But if I call LoadView("main"), it claims that main.view doesn't exist, which it does.

Here is my file structure:
+ /
|-Bedrock
|-TestFile (the file from the first spoiler)
|+ Views
||-main.view (the file from the second spoiler)

The error is:
No Loaded view. You need to do program:LoadView first
or when I add program:LoadView("main"):
Bedrock:2006: The view: main.view does not exist.

Please help me, I'm so confused

Edited by AssossaGPB, 12 October 2014 - 07:07 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users