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 


Select random option from drop-down list

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
n00tbag
How do I cheat?
Reputation: 0

Joined: 23 Aug 2023
Posts: 1

PostPosted: Wed Aug 23, 2023 9:32 am    Post subject: Select random option from drop-down list Reply with quote

I want to be able to randomly select a weapon from it's drop-down list and then hit 'Spawn Item'

I have zero experience in Lua, but was recommended by the Dark Souls CheatEngine discord that Lua may be the simplest option to execute this.

If anyone had any advice, I'd be incredibly grateful!

Thanks!

Attached image for clarity



CE_Example.jpg
 Description:
 Filesize:  96.05 KB
 Viewed:  1493 Time(s)

CE_Example.jpg


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Wed Aug 23, 2023 10:46 am    Post subject: Reply with quote

wtf does that blue text say? Can't read it in the background...

The GUI can be automated like so:
Code:
local itemScript = assert(AddressList.getMemoryRecordByDescription'Item Gib')

local function child(description)
  for i = 0, itemScript.Count - 1 do
    if itemScript.Child[i].Description == description then
      return itemScript.Child[i]
    end
  end
end

local itemSpawn = assert(child'<- Spawn Item')
local itemName = assert(child'Weapon Name')
local itemValues = {}

local ddl = itemName.DropDownList
for i = 0, ddl.Count - 1 do
  itemValues[i+1] = assert((ddl[i]):match'^%s*(%x+)%s*:', ddl[i])
end


function giveRandomItem()
  assert(itemScript.Active)
  if itemSpawn.Active then
    itemSpawn.Active = false
  end

  itemName.Value = itemValues[math.random(1,#itemValues)]
  itemSpawn.Active = true
end
Then just call giveRandomItem when you want. e.g. hotkey:
Code:
if giveRandomItemHK then giveRandomItemHK.destroy(); giveRandomItemHK = nil end
-- see `defines.lua` in the main CE directory for most `VK_WHATEVER` values
giveRandomItemHK = createHotkey(giveRandomItem, VK_NUMPAD0)

If it doesn't work and you can't figure it out (e.g. descriptions might be wrong), post any errors as well as the contents of that blue script and the spawn item script.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 Lua Scripting 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites