English Remove portal zone

5 replies
Goto Page
To the start Previous 1 Next To the start
12.01.18 08:13:48 pm
Up
AtomKuh
User
Offline Off
The following script removes every portal on a specific tile:

Code:
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:

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


Could someone edit this for me, please?

Thanks in advance
12.01.18 08:40:42 pm
Up
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):
Code:
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
12.01.18 09:22:26 pm
Up
AtomKuh
User
Offline Off
user Mora_rus 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^^
12.01.18 09:39:45 pm
Up
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.
13.01.18 12:35:44 am
Up
Avo
User
Offline Off
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