My suggestions

  • lillepallt
    8th Mar 2012 Member 0 Permalink
    @kinloch tpt is currently written in C but it's being port to C++. Try starting with a lua mod it's so much more simple..

    Edited for edit: 1. you mean like an in-game GUI for element building? I kinda like altought it still just could be private since of datacollision.. Seems unnecessary thought since we got lua..
  • _kinloch_
    8th Mar 2012 Member 0 Permalink
    I am glad its wriiten in c and is being ported to c++ as they are programing languages I am hopeing to learn.
    Lua is also on my to learn list, even more so now.

    also as far as I know when you make a lua mod with new elements the new elements are old ones that are changed so if you want one of the old onese unchanged and the lua mod then there is a problem as the old one is changed.
    I have seen a solution for this mentiond elsewhere, it was to use some of the life particles as elements to change as they aren't usealy used alongside with other elements.
    using other rarely used elements would work to.
  • SkinnySatinTiger
    8th Mar 2012 Member 0 Permalink
    Edited once by SkinnySatinTiger. Last: 3rd Oct 2022
  • _kinloch_
    8th Mar 2012 Member 0 Permalink
    @lillepallt (View Post)

    The in game GUI was partly the Idea but the other part was the poibility of having a folder in the folder where TPT goes where you could make custom elements on a text document and put them in there.A bit like autorun.lua but adds new elements not changes existing ones.
    An ingame GUI for element creation/modifying was the first pat of my idea.
    sorry if I didnt explain clearly.

    @Ben-Siraphob (View Post)
    I know.
    I am hopeing to learn c/c++ because It is a major programing language(as far as I know) and I am hopeing to learn Lua because it is used in some games(like TPT and many other games) as a programing language.
  • lillepallt
    8th Mar 2012 Member 0 Permalink
    @kinloch please correct me everybody a countless of times but I recall something on the maximum number of elements is 255 and we are quite close to that limit.. Just recalling memories from posts.. Please don't trust this until we got a safe source of developer proving this and adding statements to it.. Just rumorin'
  • _kinloch_
    8th Mar 2012 Member 0 Permalink
    @lillepallt (View Post)

    I have heard something about that 255 limit.
    Possibly my idea wouldn't work because of that.
    however I can't tell without looking at the source code of TPT(and understanding it!!).
  • boxmein
    8th Mar 2012 Former Staff 0 Permalink

    @_kinloch_ (View Post)

    @lillepallt (View Post)

    In powder.c (lines 29-37) there are five definitions of arrays that are the main arrays of the game's pixel map:

    unsigned char bmap[YRES/CELL][XRES/CELL];
    unsigned char emap[YRES/CELL][XRES/CELL];
    unsigned char cb_bmap[YRES/CELL][XRES/CELL];
    unsigned char cb_emap[YRES/CELL][XRES/CELL];
    unsigned pmap[YRES][XRES];

    I can see that the first four are character arrays(Their limit is 0-255 and they're stored as ASCII characters), but what about pmap? It doesn't have a type value! I might have heard that when you leave out the datatype when you use unsigned/signed, you get a default of int, that should mean that pmap is compatible with from 65 536 up to 4 294 967 294 elements. Though that takes us to physical limits of the computer, meaning the computer will have to remember (from powder.h "#define XRES 612 #define YRES 384") 235 008 pieces of data with 65 536 up to 4 294 967 294 values each.

  • jacksonmj
    8th Mar 2012 Developer 0 Permalink
    @boxmein (View Post)
    Look at how pmap is used. The particle type is stored using 8 bits of it - so a limit of 255 elements.
    There might be some wall numbers in the way as well, starting at 222 (in some places, wall numbers are stored in the same variable as element IDs), so the limit is probably 221 elements.

    There are currently 160 elements.
  • _kinloch_
    8th Mar 2012 Member 0 Permalink
    @jacksonmj (View Post)
    I am learning c++ so soon I will look at the code and will hopefully understand then how it works a bit more.
    Is powder toy being ported to c++?
  • Dawgie
    8th Mar 2012 Member 0 Permalink
    Well if you want custom elements use this script idk who it belongs to but kudos to them you know who you are
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    typens={'DUST','WATR','OIL','FIRE','STNE','LAVA','GUN','NITR','CLNE','GAS','C-4','GOO','ICE','METL','SPRK','SNOW','WOOD','NEUT','PLUT','PLNT','ACID','VOID','WTRV','CNCT','DSTW','SALT','SLTW','DMND','BMTL','BRMT','PHOT','URAN','WAX','MWAX','PSCN','NSCN','LN2','INSL','VACU','VENT','RBDM','LRBD','NTCT','SAND','GLAS','PTCT','BGLA','THDR','PLSM','ETRD','NICE','NBLE','BTRY','LCRY','STKM','SWCH','SMKE','DESL','COAL','LO2','O2','INWR','YEST','DYST','THRM','GLOW','BRCK','CFLM','FIRW','FUSE','FSEP','AMTR','BCOL','PCLN','HSWC','IRON','MORT','LIFE','DLAY','CO2','DRIC','CBNW','STOR','PVOD','CONV','CAUS','LIGH','TESC','DEST','SPNG','RIME','FOG','BCLN','LOVE','DEUT','WARP','PUMP','FWRK','PIPE','FRZZ','PRZW','GRAV','BIZR','BIZG','BIZS','INST','ISOZ','ISZS','PRTI','PRTO','PSTE','PSTS','ANAR','VINE','INVS','EQVE','SPW2','SPWN','SHLD','SHD2','SHD3','SHD4','LOLZ','WIFI','FILT','ARAY','BRAY','STK2','BOMB','C-5','SING','QRTZ','PQRT','EMP','BREL','','','','','','BOYL','','','','','','','H2','SOAP','BHOL','WHOL','MERC','PBCN','GPMP','CLST','WIRE','GBMB','FIGH','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','Conductor wall','E-wall','Reg wall','Streamline','Sign','Fan','Liq-only wall','Absorber','Erase walls','Wall','Air-only wall','Solid-only wall','Yellow wall','E-Hole','AIR','HEAT','COOL','VAC','Gas-only wall','WIND','Gravity wall','PGRV','NGRV','Energy wall','PROP'}
    typens[0]='NONE'
    function findelem(a)
    if (typens[a]=='')or(typens[a]==nil) then
     return a
    else
     return typens[a]..'('..a..')'
    end
    end
    psel=0
    ctype=0
    ctypet=0
    life=0
    lifet=0
    tmp=0
    tpmt=0
    tmp2=0
    tmp2t=0
    temp=273.15+22
    tempt=0
    parts={}
    function replace()
     pp={}
     local i=0
     while parts[i]~=nil do
      pp[i]=parts[i]
      i=i+1
     end
     parts={}
     i=0
     tpt.start_getPartIndex()
     while tpt.next_getPartIndex() do
      if tpt.get_property('type',tpt.getPartIndex())==psel then
       parts[i]=tpt.getPartIndex()
       i=i+1
      end
     end
     i=0
     while parts[i]~=nil do
      if pp[i]==nil then
       if ctypet==1 then tpt.set_property('ctype',ctype,parts[i]) end
       if lifet==1 then tpt.set_property('life',life,parts[i]) end
       if tempt==1 then tpt.set_property('temp',temp,parts[i]) end
       if tmpt==1 then tpt.set_property('tmp',tmp,parts[i]) end
       if tmp2t==1 then tpt.set_property('tmp2',tmp2,parts[i]) end
      end
      i=i+1
     end
    end

    function step()
    if psel~=tpt.selectedl then
     psel=tpt.selectedl
     local i=0
     parts={}
     tpt.start_getPartIndex()
     while tpt.next_getPartIndex() do
      if tpt.get_property('type',tpt.getPartIndex())==psel then
       parts[i]=tpt.getPartIndex()
       i=i+1
      end
     end
     ctype=0
     ctypet=0
     life=0
     lifet=0
     tmp=0
     tpmt=0
     tmp2=0
     tmp2t=0
     temp=273.15+22
     tempt=0
     if psel==149 then
      tmp=-1
      tmp2=-1
     end
     if psel==21 or psel==86 then life=75 end
     if psel==95 then life=10 end
     if psel==152 then tmp=10 end
     if psel==131 or psel==4 or psel==49 or psel==68 or psel==18 or psel==6 then life='~' end
     if psel==132 or psel==133 or psel==155 then tmp='~' end
     if psel==71 then life=50 end
     if psel==59 then
      life=110
      tmp=50
     end
     if psel==101 then life=100 end
     if psel==99 then life=60 end
     if psel==73 then life=110 end
     if psel==13 then ctype=2 end
     if psel==31 then life=680 end
     if psel==87 or psel==68 then temp=0 end
     if psel==97 or psel==154 then temp=273.15 end
     if psel==79 then temp=273.15+4 end
     if psel==48 then temp=273.15+9000 end
     if psel==42 then temp=273.15+67 end
     if psel==4 then temp=273.15+422 end
     if psel==57 then temp=273.15+342 end
     if psel==49 then temp=9999 end
     if psel==23 then temp=273.15+122 end
     if psel==2 or psel==25 or psel==82 or psel==111 or psel==149 or psel==95 then temp=273.15+20 end
     if psel==6 then temp=273.15+1522 end
     if psel==34 then temp=273.15+50 end
     if psel==37 then temp=273.15-203 end
     if psel==60 then temp=273.15-193 end
     if psel==66 then temp=273.15+42 end
     if psel==16 then temp=273.15-8 end
     if psel==100 then temp=273.15-183 end
     if psel==13 then temp=273.15-28 end
     if psel==51 then temp=273.15-238 end
     if psel==81 then temp=273.15-100 end
     if psel==31 then temp=273.15+922 end
     end
    drawgui()
    replace()
    end

    function drawgui()
    if al>0 then
    tpt.drawrect(4,361,603,12,255,255,255,al)
    tpt.fillrect(4,361,603,12,0,1,1,al)
    tpt.drawtext(6,363,'TYPE:'..findelem(tpt.selectedl),0,255,255,al)
    if tpt.selectedl<159 then
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<257 then tpt.fillrect(128,361,129,12,255,0,255,al/2) end
    tpt.drawtext(130,363,'CTYPE:'..findelem(ctype),255,0,0,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>256 and tpt.mousex<313 then tpt.fillrect(256,361,57,12,255,0,255,al/2) end
    tpt.drawtext(258,363,'LIFE:'..life,0,255,255,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>313 and tpt.mousex<393 then tpt.fillrect(313,361,80,12,255,0,255,al/2) end
    if cels==0 then
    tpt.drawtext(314,363,'TEMP:'..temp..'K',255,0,0,al)
    else
    tpt.drawtext(314,363,'TEMP:'..(temp-273.15)..'C',255,0,0,al)
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>393 and tpt.mousex<447 then tpt.fillrect(393,361,54,12,255,0,255,al/2) end
    tpt.drawtext(394,363,'TMP:'..tmp,0,255,255,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>447 and tpt.mousex<605 then tpt.fillrect(447,361,160,12,255,0,255,al/2) end
    tpt.drawtext(448,363,'TMP2:'..tmp2,255,0,0,al)
    end
    end
    end

    function click(x,y,btn,ev)
     if ev==2 and btn==1 and tpt.selectedl<159 then
      if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<257 then
       a=tpt.input('','Enter new CTYPE:',ctype)
       s=tonumber(a)
       if s~=nil then
        ctype=s
        ctypet=1
       else
        local i=0
        for i=0,158 do
         if string.upper(typens[i])==string.upper(a) then
          ctype=i
          ctypet=1
          break
         end
        end
       end
      end
      if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>256 and tpt.mousex<313 then
    s=tonumber(tpt.input('','Enter new LIFE:',life))
    if s~=nil then
     life=s
     lifet=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>313 and tpt.mousex<393 then
    s=tonumber(tpt.input('','Enter new TEMP:',temp))
    if s~=nil then
     temp=s
     tempt=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>393 and tpt.mousex<447 then
    s=tonumber(tpt.input('','Enter new TMP:',tmp))
    if s~=nil then
     tmp=s
     tmpt=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>447 and tpt.mousex<605 then
    s=tonumber(tpt.input('','Enter new TMP2:',tmp2))
    if s~=nil then
     tmp2=s
     tmp2t=1
    end
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<605 then return false end
    end
    tgl=1
    function key(a,b,c,d)
     if (b==308 or b==304)and c==257 and event==1 then
      ctypet=1
      ctype=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      lifet=1
      life=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tempt=1
      temp=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tmpt=1
      tmp=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tmp2t=1
      tmp2=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
     end
     if a=='e' and d==2 then
      tgl=1-tgl
      if tgl==0 then
       tpt.unregister_step(step)
       tpt.unregister_mouseclick(click)
      else
       tpt.register_step(step)
       tpt.register_mouseclick(click)
      end
     end
    end
    tpt.register_step(step)
    tpt.register_mouseclick(click)
    tpt.register_keypress(key)
    al=200
    cels=1