English Portal name

6 replies
Goto Page
To the start Previous 1 Next To the start
12.07.18 12:59:31 pm
Up
tos12345678
User
Offline Off
Whether there is a parse spawnobject (orange portal) with name and trigger? Can I name this spawnobject (not editor)?
12.07.18 03:24:02 pm
Up
Yates
Reviewer
Offline Off
cs2d cmd spawnobject has written:
IMG:https://i.imgur.com/H9BdsK4.png

Where's Wally? Wally knows.
12.07.18 04:12:26 pm
Up
tos12345678
User
Offline Off
I mean Name, Trigger which I can interact with
e.g. When i enter this portal, it is exit.

Put simply this spawnobject have a name: test1 and trigger: test2
to interact with others e.g. delay, dynWall and similar.
I want to this object
Code:
1
parse("spawnobject 22 "..player(id,"tilex").." "..player(id,"tiley"))

exitting after 30seconds.
12.07.18 04:39:45 pm
Up
VADemon
User
Offline Off
No, you need a Lua script for this (to trigger entities from portal enter/exit)
I will do one tomorrow - PM me if I forget.
https://youtu.be/OlX8havmldo | thread cs2d 【東方】Bad Apple!! 【影絵】 in CS2D | Propaganda, Werbung für Waren (Reklame), Lehren und Ideen, besonders auf dem Gebiete der Politik, um Anhänger zu werben; z.B. Wahlpropaganda durch Versammlungen, Rundfunkreden, Plakate und Flugblätter
12.07.18 04:48:59 pm
Up
tos12345678
User
Offline Off
Okey √
16.07.18 07:27:35 pm
Up
VADemon
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
portaltrigger = {}
portaltrigger.pos = {}

addhook("movetile", "portaltrigger_movetile")

-- movetile is also triggered when player is teleported or setpos is used
function portaltrigger_movetile(id, tilex, tiley)
     tilex, tiley = tonumber(tilex), tonumber(tiley)
     --msg("movetile: ".. id ..", ".. tilex ..", ".. tiley)
     
     if portaltrigger.pos[tilex] and portaltrigger.pos[tilex][tiley] then
          local oid = objectat(tilex, tiley, 22) or objectat(tilex, tiley, 21)
          --msg("oid is ".. tostring(oid))
          if oid then
               parse("trigger portaltrg@".. tilex .. "_".. tiley)
          end
          
     --else
          --msg(tilex ..", ".. tiley .." doesnt exist")
     end
end

-- Multiplayer Trigger BUG
--[[
addhook("trigger", "portaltrigger_trigger")
yellow = 0
blue = 0
function portaltrigger_trigger(trigger, source)
     msg("trigger: ".. trigger .." src: ".. tostring(source))
     
     if trigger and trigger == "yellow" then
          yellow = yellow + 1
     elseif trigger and trigger == "blue" then
          blue = blue + 1
     end
     
     parse("hudtxt 0 \"yellow = ".. yellow .."\" 0 420")
     parse("hudtxt 1 \"blue = ".. blue .."\" 0 435")
end
]]
function portaltrigger.init()
     local elist = entitylist()
     for i, e in pairs(elist) do
     
          local name = entity(e.x, e.y, "name")
          for keyword, tilex, tiley in name:gmatch("(%w+)@(%d+)_(%d+)") do
               
               if keyword and tilex and tiley then
                    keyword = keyword:lower()
                    tilex, tiley = tonumber(tilex), tonumber(tiley)
                    if keyword == "portaltrg" then
                         print("PortalTrigger registered at ".. tilex ..",".. tiley)
                         if not portaltrigger.pos[tilex] then portaltrigger.pos[tilex]={} end
                         portaltrigger.pos[tilex][tiley] = true
                    end
               end
          end
     end
end
portaltrigger.init()


How To:
1) Put this script to sys/lua/autorun
OR
1) Name this script the same as your map and add it to maps/ e.g. /maps/<mapname>.lua & /maps/<mapname>.map

Make entities:
2) Spawn any Orange/Blue portal. For example, Portal is at position X14, Y18 - it works for Entity portal and for Player portals in-game created with Portal Gun
3) Create Entity in Editor that will be triggered when player visits portal at X14, Y18:
Example: cs2d entity env_explode put "portaltrg@14_18" as Name!
- Every time a player goes to a portal at X14 Y18 it will be triggered
4) Done. You can have many entities to trigger when player visits this portal.
You can also give this entity many names e.g. "portaltrg@14_18,portaltrg@10_10" - I think CS2D allows it, but please test it

PS: So it's the other way around. You can spawn any portals with spawnentity, but instead of saying in spawnentity what will be triggered, you must have entities on map with the Name: field specified, telling that it will be triggered once a player visits a portal at X,Y. "portaltrg@X_Y"
https://youtu.be/OlX8havmldo | thread cs2d 【東方】Bad Apple!! 【影絵】 in CS2D | Propaganda, Werbung für Waren (Reklame), Lehren und Ideen, besonders auf dem Gebiete der Politik, um Anhänger zu werben; z.B. Wahlpropaganda durch Versammlungen, Rundfunkreden, Plakate und Flugblätter
16.07.18 09:39:19 pm
Up
tos12345678
User
Offline Off
Thanks for answer
To the start Previous 1 Next To the start