Forum

> > CS2D > Scripts > Remove portal zone
Forums overviewCS2D overview Scripts overviewLog in to reply

English Remove portal zone

5 replies
To the start Previous 1 Next To the start

old Remove portal zone

AtomKuh
User Off Offline

Quote
The following script removes every portal on a specific tile:

1
2
3
4
5
6
7
addhook("always","removeportal")
function removeportal(x,y)
     local obj = math.max(objectat(x,y,22),objectat(x,y,23))
     if obj > 0 then
          parse("killobject "..obj)
     end
end

I would like to add a zone instead of just one tile for the portal remover zone.

For Example:

1
2
3
zone = {
     {8,6,12,10},
}

Could someone edit this for me, please?

Thanks in advance

old Re: Remove portal zone

Mora
User Off Offline

Quote
I think if i'd do that i'd use cs2d lua hook buildattempt and a table with zones like you said to disallow buildings on specific area on BUILD ATTEMPT that triggered when you trying to build forbidden building than always go through all zones and remove these.

What exactly type(s) of building you wanne be removed/not allowed to being built?

i made the example of what i mean, if you wanna different, type in discord(i have it in my profile):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
zones = {
 [1] = {{2,2},{5,5}},
 [2] = {{7,2},{10,15}}
}

addhook("buildattempt","_ba")
function _ba(id,type,x,y,mode)
	if type==13 or type==14 or type==22 or type==23 then
		for i=1,#zones do
			if (x >= zones[i][1][1] and x <= zones[i][2][1]) and (y >= zones[i][1][2] and y <= zones[i][2][2]) then
				return 1
			end
		end
	end
end
I guess it should work.
But if you so want to use zones in awlays.. use the 10-th line example in always and copy zones and type there your own
edited 1×, last 12.01.18 08:54:29 pm

old Re: Remove portal zone

AtomKuh
User Off Offline

Quote
user Mora has written
What exactly type(s) of building you wanne be removed/not allowed to being built?


I just want to disable portals (created by portal guns)

Your script disables teleport exit/entrance but I cans still shoot portals^^

old Re: Remove portal zone

Mora
User Off Offline

Quote
I was quickly done it and you can change the 8-th line to:
if type==22 or type==23 then

Oh wait, you said you can? Hmm.. lemme see what i can do.
It must be a bug then. I have no thoughts about portalguns. They should be included in build/buildattempt at least because they included in buildings.

old Re: Remove portal zone

Avo
User Off Offline

Quote
It's not the best way, but you can use attack and attack2 hooks and check if player uses a portal gun.

If he does - remove the portal. How to achieve this? You can send request to get coordinates of player's mouse and use it to find a proper tile. You can also find the created object using object lua function (I mean
object(0,"table")
).
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview