Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


LUA Script used to make 'terraria materials spawner'.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4151
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Jun 12, 2011 8:02 am    Post subject: LUA Script used to make 'terraria materials spawner'. This post has 1 review(s) Reply with quote

Code:
-- SPAWN POINT PATTERN, left side
searchthis=[[
?? ?? ?? ?? 01 01 01 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? ?? 00 01 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? ?? 01 01 1E ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? ?? 01 01 01 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? ?? 01 01 1E ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
?? ?? ?? ?? 00 01 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
]]

searchthis=string.gsub(searchthis,"\n"," ")

ms = createMemScan()
FL = createFoundList(ms) 
memscanusedbefore=false

WorldHeight = 1200
spawnpoint_table = {}

function findSpawnpoints()

  control_setCaption(UDF1, "Terraria Materials Spawner. Searching...")

  if (memscanusedbefore==true) then foundlist_deinitialize(FL) end
  memscanusedbefore=true

  memscan_firstScan(ms, soExactValue, vtByteArray, rtRounded, searchthis,
                  "", 0x00000000, 0x7fffffff, "+W-X-C", fsmNotAligned, "",
                  true, false, false, false)


  memscan_waitTillDone(ms)
  foundlist_initialize(FL)

  spawnpoint_table = {}
 
  FlCount = foundlist_getCount(FL)
  if (FlCount == 0 ) then return end
 
  WorldHeight=(combobox_getItemIndex(CBworldSize)+2)*600

  for index=0,FlCount-1 do
      address = tonumber(foundlist_getAddress(FL,index),16)
      nextcolumncheck = readBytes(address+WorldHeight*24, 24*6, true)

      if (nextcolumncheck ~= nil) then

        if (nextcolumncheck[24*0+6]==1 and nextcolumncheck[24*1+6]==1 and nextcolumncheck[24*2+6]==1 and
            nextcolumncheck[24*3+6]==30 and nextcolumncheck[24*4+6]==30 and nextcolumncheck[24*5+6]==0) then

            table.insert(spawnpoint_table,address)
            end
      end
  end

end

function SpawnPointQuickCheck(spawnpointID)

    quickSpawnPointCheck_bytes = readBytes(spawnpoint_table[spawnpointID], 24*7, true)

    if (quickSpawnPointCheck_bytes == nil) then return false
    else
      if (quickSpawnPointCheck_bytes[24*0+6]==1 and quickSpawnPointCheck_bytes[24*1+6]==0 and
          quickSpawnPointCheck_bytes[24*2+6]==30 and quickSpawnPointCheck_bytes[24*3+6]==1 and
          quickSpawnPointCheck_bytes[24*4+6]==30 and quickSpawnPointCheck_bytes[24*5+6]==0) then
        return true end

      return false
    end

end

function button1click(secondtry)

  if (terrariaexeopened==false) then return end

  -- first time click check
  if ((# spawnpoint_table) == 0) then
    findSpawnpoints()
    if ((# spawnpoint_table) == 0) then
      control_setCaption(UDF1, "Terraria Materials Spawner. No trainer spawn points.")
      return false
    end
  end
  -- first time click check

  control_setCaption(UDF1, "Terraria Materials Spawner")

  material = combobox_getItemIndex(CBmaterial)+6

  spawnsuccess = false
  --lua tables starts from 1
  for index=1,(# spawnpoint_table) do
    if (SpawnPointQuickCheck(index) == true) then
      spawnsuccess=true
      writeBytes(spawnpoint_table[index]+2*24*WorldHeight+24*0,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+2*24*WorldHeight+24*1,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+2*24*WorldHeight+24*2,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+2*24*WorldHeight+24*3,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+2*24*WorldHeight+24*4,255,255,255,255,1,1,material)

      writeBytes(spawnpoint_table[index]+3*24*WorldHeight+24*0,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+3*24*WorldHeight+24*1,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+3*24*WorldHeight+24*2,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+3*24*WorldHeight+24*3,255,255,255,255,1,1,material)
      writeBytes(spawnpoint_table[index]+3*24*WorldHeight+24*4,255,255,255,255,1,1,material)
      end
  end
 
  if (spawnsuccess == true) then beep() end

  if ((spawnsuccess == false) and (secondtry~="secondtry")) then
                            spawnpoint_table = {}
                            button1click("secondtry")
                            end

end

function button2click()
  if (terrariaexeopened==false) then return end
 
  beep()
  spawnpoint_table = {}
  button1click()
end

terrariaexeopened=false

function onOpenProcess(processid)
  terrariaexeopened=true
end

addresslist=getAddressList()
memrec0 = addresslist_getMemoryRecordByID(addresslist, 0)
memrec0_hotkey0=memoryrecord_getHotkeyByID(memrec0,0)
memoryrecordhotkey_onHotkey(memrec0_hotkey0,button1click)

memrec1 = addresslist_getMemoryRecordByID(addresslist, 1)
memrec1_hotkey0=memoryrecord_getHotkeyByID(memrec1,0)
memoryrecordhotkey_onHotkey(memrec1_hotkey0,button2click)

strings_add(getAutoAttachList(), "terraria.exe")
form_show(UDF1)

function HelpButton1Click(sender)
  form_hide(UDF2)
end

function CEButton4Click(sender)
  form_show(UDF2)
end

CBmaterial=component_findComponentByName(UDF1, "TerrariaMaterialComboBox1")
CBworldSize=component_findComponentByName(UDF1, "worldSizeComboBox1")



function CloseClick()
  closeCE()
  return caFree --onClick doesn't care, but onClose would like a result
end

control_setCaption(UDF1, "Terraria Materials Spawner")

function CELabel1Click(sender)
  shellExecute('http://tnij.org/TMST_youtube')
end

function CELabel2Click(sender)
  shellExecute('http://tnij.org/TMST_forumthread')
end

_________________
Back to top
View user's profile Send private message MSN Messenger
Nemexia55
Expert Cheater
Reputation: 0

Joined: 28 Jan 2014
Posts: 158

PostPosted: Tue Dec 16, 2014 1:02 pm    Post subject: Reply with quote

Do you know how can I learn lua? I really want to learn it.
I just know a bit of these:
C++,basic,visual basic, assembly Sad
Sad Sad

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites