Forum

> > CS2D > Maps/Editor > How to use Trigger_If
Forums overviewCS2D overview Maps/Editor overviewLog in to reply

English How to use Trigger_If

5 replies
To the start Previous 1 Next To the start

old How to use Trigger_If

MikuAuahDark
User Off Offline

Quote
Note: use CTRL+F to find the contens

∗ Contens
> Introduction
> How to use
> How to use(Example)
> FAQ
> Credits

∗ Introduction
Trigger_If is a entity that allow you to use if statement on lua scripts

∗ How to use
Put Trigger_If on your map, fill the "name", "trigger", and Condition. Condition can be this way
• entity(0,0,"typename")=="Trigger Delay"
or you can see 2 examples at there
then link it with a Trigger_Use, Hit, Move, etc.

∗ How to use(Example)
1. create 2 CT spawnpoint with different name(ct1 and ct2) and 1 T spawnpoint(to prevent crash)
2. create Func_DynWall and 2 Trigger_Use(1 trigger CT spawnpoint(ct2) and another to trigger the Trigger_If)
• Hint: it should like this

IMG:https://i46.tinypic.com/2qved86.png

3. Create Trigger_If and Fill the condition this way:
•
1
entity(2,0,'state')==true
• Hint: to make less confusing here the data that needed to filled at entity
> Tile 0|0 Info_T
> Tile 1|0 Info_CT Name: ct1
> Tile 2|0 Info_CT Name: ct2
> Tile 2|4 Trigger_Use Trigger: iftest Button: Lighted Red
> Tile 2|6 Trigger_Use Trigger: ct2 Button: Red Alarm
> Tile 3|5 Func_DynWall Name: dwall Tile: 0
> Tile 3|4 Trigger_If Name: iftest Trigger: dwall Condition: entity(2,0,'state')==true
• Note: Name, Trigger are in case sensitive
4. Make sure that Trigger_If trigger the Func_DynWall and 1 Trigger_Use trigger the Trigger_If
5. Save the map and test it. And make sure there is a 6 bots with CT
6. It should spawn on 2 spawnpoint
7. okay go to Trigger_Use that linked to Trigger_If and press "Use" key
8. If it works fine the door should not open, go to Trigger_Use that linked to Info_CT(with name ct2) and press "use" key
9. Try to kill yourself 10 times to MAKE sure that there is a only 1 spawnpoint
10. If it works fine you should ALWAYS spawn on Info_CT(with name ct1)
11. Repeat step 7 and see if it works. If it works fine the door should open
12. If it open you did it right, but if not seems that you did something wrong. Retry again the tutorial

∗ FAQ
> Q: Can i use a variable that used on my lua scripts?
> A: Yes

> Q: Can i use a returned function value as value of the statement?
> A: Yes, function values r just as valid as variable and constant values

> Q: Can i use function instead of variable that on my lua scripts?
> A: Of course you can

> Q: Can i create script with Trigger_If?
> A: Yes you can for example this file file cs2d Automated Shop

> Q: Is a allowed to load scripts from Trigger_If?
> A: Of course, it's gonna used on RL Roleplay Citylife's map. Just create Trigger_If and fill the condition this way:
1
dofile("<Luapath>")

∗ Credits
user omg - He tell me the answer of the FAQ 2
user Apache uwu - He PM me, i ask "can i put your files as another example". you can see it at FAQ 4
user VADemon - See FAQ 5

° Marked as Inportant thread. I hope this thread marked as important

• Note: Correct me if im wrong
edited 5×, last 08.08.12 01:38:42 pm

old Re: How to use Trigger_If

omg
User Off Offline

Quote
Q: Can i use a returned function value as value of the statement?

yes, function values r just as valid as variable and constant values

old Re: How to use Trigger_If

VADemon
User Off Offline

Quote
You can even make working preloaded scripts:
Trigger_if:
1
load_mymap("de_desert")

Lua script:
1
2
3
function load_mymap(name)
dofile("sys/lua/maps/"..name..".lua")
end
edited 1×, last 21.11.17 01:58:12 pm

old Re: How to use Trigger_If

StirlizZ-Fapicon
Super User Off Offline

Quote
Is it possible to use this entity for using simple lua actions now?

Because in version 1.0.0.2 it was possible to parse spawnprojectiles without additional lua file (which is sucks).

@user DC: , any updates of trigger_if was since that release?

I`m do necroposting and asking that because it was an AWESOME way to implement lua scripts into map without using additional .lua files (which is sucks x2).

old Re: How to use Trigger_If

DC
Admin Off Offline

Quote
Trigger_If has been extended with additional pre-defined conditions some releases ago. Its original functionality however (which allows Lua execution and evaluation) is still there and should still work.

There's a setting related to this however
cs2d cmd mp_luamap and it defaults to 0 for security reasons (custom maps might contain malicious Lua). You have to set it to 1 to make all map-related scripts (map Lua files and trigger_if) work.
To the start Previous 1 Next To the start
Log in to reply Maps/Editor overviewCS2D overviewForums overview