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

Archived

This topic is now archived and is closed to further replies.

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

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

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

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

 

Share this post


Link to post
Share on other sites

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

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

×
×
  • Create New...

Important Information

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