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

Call a variable in a command

Question

Posted

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

4 answers to this question

Recommended Posts

  • 2
Posted

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

 

  • 0
Posted

I got the same error message

open1.PNG.5d962fdf6afe3452e3217820e3102dfb.PNG

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

 

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.