Page 2 of 2

Re: Is it possible to locate an item via console using item ID?

Posted: Mon Jul 10, 2023 10:30 pm
by sapientCrow

Code: Select all

do 
	local_item_id = "tome_wisdom" 
	
	for index = 1, Dungeon:getMaxLevels() do 
		for item in Dungeon.getMap(index):allEntities() do 
			if item.id == local_item_id then 
				hudPrint("A matching item was found in "..item.map:getName().." ".."(level "..item.level..") @ tile X:"..tostring(item.x)..",Y:"..tostring(item.y)) 
				setMouseItem(item.item) 
				playSound("secret") party:spawn('blob') 
				return 	
			end 
		end 
	end 
	hudPrint("No matching item was found")
end

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 12:15 am
by Isaac
Ah... Sorry, I mean't for you to post your spawn command as you typed in the game.

When I use the script in the editor preview, it locates the book (if it exists on the floor) within the dungeon. So I wanted to see your spawn command, to see the id that it generates. Lua is case sensitive, and any variation (even letter case) will not pass the equality check.

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 1:32 am
by sapientCrow
spawn "tome_wisdom"


is there a console command to hold an item and have it return the ID? or name

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 2:31 am
by Isaac
sapientCrow wrote: ↑Tue Jul 11, 2023 1:32 am spawn "tome_wisdom"
This will generate a tome_wisdom object with a numerical id.

*You can check this id string by holding the tome item on the mouse cursor, and pasting the following into the console:

Code: Select all

print(getMouseItem().go.id)
To spawn an object in console with a specified id string, you can use this:

Code: Select all

spawn("tome_wisdom",nil,nil,nil,nil,nil,"your_id")
*Checkable with the above getMouseItem() function. The spawn will fail if there is already an object with that name.

Alternatively you can fill out the parameters for the Spawn function instead of using 'nil'. This lets you spawn it on a specific map, tile, face direction, and elevation.

Code: Select all

spawn(object, level, x, y, facing, elevation, id)
* https://github.com/JKos/log2doc/wiki/Gl ... ions#spawn

** BTW, objects with numerical id strings are not directly accessible—because you cannot use their id's directly. To access generated objects like these you can use findEntity() for this.

Code: Select all

print(findEntity("47").name)

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 3:06 pm
by sapientCrow
Thank you so much!

All of this was really helpful for mean now I understand the difference between setting and spawning too as far as ID/name goes.

thanks again for the help!!

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 3:14 pm
by sapientCrow
I guess if it has a numerical ID it is not possible to do a search for it with the level search code right?

Re: Is it possible to locate an item via console using item ID?

Posted: Tue Jul 11, 2023 3:30 pm
by Isaac
If you know the numerical id#, you can put that inside the quotes, and it should work.

Code: Select all

local_item_id = "140"