Forum

> > CS2D > Scripts > How does the removeitem work?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How does the removeitem work?

5 replies
To the start Previous 1 Next To the start

old How does the removeitem work?

Mami Tomoe
User Off Offline

Quote
Hi this is a question and a problem.
I want to remove a fancy looking snowball at the position of: 98,106

Now I wanted to use this but I have no clue how to use it.

Please help me by explaining how does it work or giving me a easy function to learn from.

Also I really like pens (the blue ones)

old Re: How does the removeitem work?

Yates
Reviewer Off Offline

Quote
You will have to loop through the list of items on the map like so:
1
2
3
4
local itemlist=item(0,"table")
for _,id in pairs(itemlist) do
   print(item(id,"name"))
end

Then once you have found the item
x
and
y
you are looking for you can use that item's
type
to remove it from the map with cs2d cmd removeitem

old Re: How does the removeitem work?

Cure Pikachu
User Off Offline

Quote
@user Yates: Pretty sure you use the item's internal ID to remove an item from the map using cs2d cmd removeitem.

So it would be something like:
1
2
3
4
5
6
7
for _, iid in pairs(item(0,"table")) do
	if item(iid,"exists") and item(iid,"type") == 75 then
		if item(iid,"x") == 98 and item(iid,"y") == 106 then
			parse("removeitem "..iid)
		end
	end
end

old Re: How does the removeitem work?

Yates
Reviewer Off Offline

Quote
@user Cure Pikachu: From the documentation, cs2d lua cmd item has
type
which is referred to as the internal item id.

Or am I confused again with CS2D's way with item ids?

• Edit: Oh, found it!
Quote
item(0,"table"): returns a Lua table with all dropped item IDs (the unique instance IDs, NOT the type IDs!)

You are correct.
edited 1×, last 13.07.16 06:41:17 pm

old Re: How does the removeitem work?

Yates
Reviewer Off Offline

Quote
Indeed. These notices need to be a big bigger and brighter if you ask me. I always seem to miss them and I hope I'm not the only one
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview