Script not working

  • FeynmanLogomaker
    14th Apr 2013 Member 0 Permalink

    function elementmod()
    elemtype=tpt.input("Element to edit","This is the element the script will modify")
    scriptname = tpt.input("Script Name","This will be the name of the generated script")
    file = io.open(scriptname, "w")
    file:write("tpt.el.",elemtype,"name=",tpt.input("New name","This will be the new name of the element"))
    file:write("tpt.el.",elemtype,"description=",tpt.input("New description","This will be the new description of the element"),"\n")
    file:write("tpt.el.",elemtype,"color=",tpt.input("New color","This will be the new color of the element"),"\n")
    file:write("tpt.el.",elemtype,"menusection=",tpt.input("New menusection","This will be the new menusection of the element"),"\n")
    file:write("tpt.el.",elemtype,"gravity=",tpt.input("New gravity","This will be the new gravity of the element"),"\n")
    file:write("tpt.el.",elemtype,"flammable=",tpt.input("New flammability","This will be the new flammability of the element"),"\n")
    file:write("tpt.el.",elemtype,"explosive=",tpt.input("New explosivity","This will be the new explosivity of the element"),"\n")
    file:write("tpt.el.",elemtype,"loss=",tpt.input("New loss","This will be the new loss of the element"),"\n")
    file:write("tpt.el.",elemtype,"airloss=",tpt.input("New airloss","This will be the new airloss of the element"),"\n")
    file:write("tpt.el.",elemtype,"airdrag=",tpt.input("New airdrag","This will be the new airdrag of the element"),"\n")
    file:write("tpt.el.",elemtype,"advection=",tpt.input("New advection","This will be the new advection of the element")," \n")
    file:write("tpt.el.",elemtype,"weight=",tpt.input("New weight","This will be the new weight of the element"),"\n")
    file:write("tpt.el.",elemtype,"diffusion=",tpt.input("New diffusion","This will be the new diffusion of the element"),"\n")
    file:write("tpt.el.",elemtype,"heat=",tpt.input("New heat","This will be the new creation temperature of the element"),"\n")
    end

     

    Why won't that write anything in the file? It creates an empty file, but it also leaves it empty.

  • cracker64
    14th Apr 2013 Developer 0 Permalink

    You never file:flush() or file:close(), at least I'm pretty sure that is why.

  • FeynmanLogomaker
    14th Apr 2013 Member 0 Permalink

    ohh...

     

    --Actually, I tried both, that made it not even create the file.

    Lol, somehow I'm not surprised that no one is suggesting anything. If Cracker can't flawlessly fix a script first try, it will never work.

  • cccp2
    1st May 2013 Banned 0 Permalink
    This post is hidden because the user is banned
  • TPTROXRLYITSTRUE
    2nd May 2013 Banned 0 Permalink
    This post is hidden because the user is banned
  • cccp2
    2nd May 2013 Banned 0 Permalink
    This post is hidden because the user is banned
  • boxmein
    2nd May 2013 Former Staff 0 Permalink
    This literally does tens of prompts asking to modify an existing element (boo, there's already a better way to edit elements!)

    For a ...umm, better option, you might want to look at
    http://boxmein.net/tpt/tptelements/reference/lua-reference.html
    Edited 3 times by boxmein. Last: 10th Apr 2016