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

Call a variable in a command

Question

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^^.

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({...})

 

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.