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

Call a variable in a command


Hello guys,

I tried the print fuction and it works perfectly but it's boring to type every times the command : print3d /usr/share/models/...

So I wanted to edit a program so I can just write what I need to print (netherportal/pillar_mid/...)

local term = require("term")

print("what do you want to print?")

answer = io.read() -- Here I write the thing I want to print netherportal/pillar_mid/...

os.execute("print3d /usr/share/models/,answer,.3dm) -- And I d'like to call it in that line but how, i don't know


apparently it doesn't work so if you can help me, be fine and help me^^.

Share this post

Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 2

You are correct. I thought for some reason that was an example you inserted to say ...this model...

The 'answer' var is a string returned from either term.read() or io.read() (excuse my first advice. term.read is probably better...). The line you're looking for is this..

os.execute("print3d /usr/share/models/" .. answer .. ".3dm") -- # string concatenation
-- # OR
os.execute(table.concat({"print3d ", "/usr/share/models/", answer, ".3dm"})) -- # Using table.concat({...})


Share this post

Link to post
Share on other sites
  • 0

Replace require 'term' with 'io'. You don't use term lib but you are using the io lib. If that's not your issue please post the full code and resulting error please.

Share this post

Link to post
Share on other sites
  • 0

I got the same error message


I think the error is in the last line (.../,answer,...) because I tried it without knowing how to insert a variable into a program path.open2.PNG.4388963ed2fc436bf59a9d360e6e084d.PNG


Share this post

Link to post
Share on other sites
  • 0

you don't need to require("io"), that is a global library

you don't need to require("term") simply because you weren't using it

Share this post

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.

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.


  • Create New...

Important Information

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