Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Turboclonerider

Need help with my program

Question

4 answers to this question

Recommended Posts

  • 0

  • The first line doesn't do what you think. All it does is assign the string "component.redstone" to the variable c. If you want to use the redstone component, you first have to load the component library using local component = require("component"). You'll also want to load the sides library the same way, because you later need to say what side to read the signal from.

The third line is what's causing your error. On the wiki, functions are written like getInput(side: number): number. This means that the function takes one argument of type number and returns a number. However this is not normal Lua syntax, so you cannot just copy over the function from the wiki. In your case, you'll want to call the function like local signal = component.redstone.getInput(sides.back). This calls the redstone component's function getInput and gives it the argument sides.back. We've loaded the sides library before, and sides.back is actually a number that stands for a side. The function returns the redstone signal strengh as a number, which we store in the variable signal. (If you don't assign the return value to a variable, it is "thrown away" and you cannot use it later.)

Lua is case-sensitive. If is not the same as if. if is a keyword for the if statement (which is what you want here). If is a normal variable name like any other.

= is the assignment operator, used to store something in a variable. To check if two things are equal, you need to use the equality operator ==. One equals is for storing things, two equals is for comparing them.

Unlike in some languages, in Lua the string "0" is not the same as the number 0. So if you want to check if a number is zero, you need to write if signal == 0 then etc.

Link to post
Share on other sites
  • 0

You can use component.gpu.setResolution to reduce the resolution, which (like most real monitors nowadays) means that the text is upscaled and looks larger. This only affects the text size on the screen block in the world, in the right-click GUI for the screen it will just make the "window" smaller. You might also want to use more than one monitor block - for the default resolution I find a 3*2 screen works well.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.