autorun.lua Adding more than one script

  • MassacreLand
    31st Jan 2012 Member 0 Permalink
    I wish to add more than one element script to my autorun.lua but each time they cancel eachother out.
    How do I add more than one script?
  • mniip
    31st Jan 2012 Developer 0 Permalink
    @MassacreLand (View Post)

    make sure their namespaces dont intersect
  • MassacreLand
    31st Jan 2012 Member 0 Permalink
    @mniip (View Post)
    I'm sorry I am a noob when it comes to lua haha I can edit but not create.

    Thats about the height of my intellect.

    Could you either explain further or show a small example? Please an thank you!
  • mniip
    31st Jan 2012 Developer 0 Permalink
    mkay.

    if one mod has function step(), and another has function step(), they will run ok if separately, but if merged, it will cause lots of errors.
  • MassacreLand
    31st Jan 2012 Member 0 Permalink
    @mniip (View Post)
    Lol Sorry I am still pretty confused. I understand the scripts alone work but together cause errors. But I still have no clue how to add them together >.<. Thank you for helping me though! You have helped alot tonight for sure.

    Could I possibly add 2 or more elements to one script? Instead of 2 or more element scripts to the autorun file?

    That way only one script is running but that one script is told to create more than one element?


  • mniip
    31st Jan 2012 Developer 0 Permalink
    give me both scripts :|
  • MassacreLand
    31st Jan 2012 Member 0 Permalink
    @mniip (View Post)
    Lol  I'm sorry. I used to know some of lua and all that but tht was on a different game and even without that i didnt know much.

    tpt.el.wind.name='EWAT'
    tpt.el.wind.description='Angry water.'
    tpt.el.wind.color=0x84BFD5
    tpt.el.wind.menusection=4
    tpt.el.wind.menu=1
    tpt.el.wind.enabled=1
    tpt.el.wind.weight=-1
    types={'hygn','oxyg'}
    math.randomseed(os.time())
    function ewat(i,x,y,s,n)
    for n=1,2 do
    tpt.parts[i].x=tpt.get_property('x',i)+math.random(-6,6)
    tpt.parts[i].y=tpt.get_property('y',i)+math.random(-6,6)
    for x2=-7,7 do
    for y2=-math.sqrt((49)-(x2^2)),math.sqrt((49)-(x2^2)) do
    tpt.create(x+x2,y+y2,types[math.random(1,2)])
    tpt.set_property('life',4,x+x2,y+y2)
    tpt.set_property('temp',-10000+273.15,x+x2,y+y2)
    if tpt.get_property('type',x+x2,y+y2)~=0 and tpt.get_property('type',x+x2,y+y2)~=tpt.el.oxyg.id and tpt.get_property('type',x+x2,y+y2)~=tpt.el.hygn.id and tpt.get_property('type',x+x2,y+y2)~=tpt.el.wind.id then
    tpt.create(x+x2,y+y2,'watr')
    tpt.set_property('life',10,x+x2,y+y2)
    end
    end
    end
    end
    end

    tpt.element_func(ewat,tpt.el.wind.id)


    tpt.el.wind.name='RAGE'
    tpt.el.wind.description='Rage?'
    tpt.el.wind.color=0x800080
    tpt.el.wind.menusection=3
    tpt.el.wind.menu=1
    tpt.el.wind.enabled=1
    tpt.el.wind.weight=-1
    types={'fire','thrm'}
    math.randomseed(os.time())
    function rage(i,x,y,s,n)
    for n=1,2 do
    tpt.parts[i].x=tpt.get_property('x',i)+math.random(-6,6)
    tpt.parts[i].y=tpt.get_property('y',i)+math.random(-6,6)
    for x2=-7,7 do
    for y2=-math.sqrt((49)-(x2^2)),math.sqrt((49)-(x2^2)) do
    tpt.create(x+x2,y+y2,types[math.random(1,2)])
    tpt.set_property('life',4,x+x2,y+y2)
    tpt.set_property('temp',10000+273.15,x+x2,y+y2)
    if tpt.get_property('type',x+x2,y+y2)~=0 and tpt.get_property('type',x+x2,y+y2)~=tpt.el.thrm.id and tpt.get_property('type',x+x2,y+y2)~=tpt.el.fire.id and tpt.get_property('type',x+x2,y+y2)~=tpt.el.wind.id then
    tpt.create(x+x2,y+y2,'rage')
    tpt.set_property('life',10,x+x2,y+y2)
    end
    end
    end
    end
    end

    tpt.element_func(rage,tpt.el.wind.id)

  • limelier
    31st Jan 2012 Member 0 Permalink
    Well duh. They both replace wind.
  • MassacreLand
    31st Jan 2012 Member 0 Permalink
    @tudoreleuu (View Post)

    Not true. Wind and the element still both exist ingame.

    That and changing the wind to a different element in the other script does the same thing as not replacing it.
  • mniip
    31st Jan 2012 Developer 0 Permalink
    @MassacreLand (View Post)
    there's no element called wind.
    The one you see in tools menu is not an element, its a tool.