Forum

> > CS2D > General > random_trigger
Forums overviewCS2D overviewGeneral overviewLog in to reply

English random_trigger

5 replies
To the start Previous 1 Next To the start

old Re: random_trigger

Kiffer-Opa
User Off Offline

Quote
When you expect good answers, you have to ask good questions.
For a good answer, you should tell what exactly do you expect from a "random_trigger".
Is it an entity? When should it trigger? Do you want to use Lua?

If we don't know this, we hardly can help you; also DC.


All I can say that Lua has a function for random numbers:
1
math.random(min,max)
This gives you a random number between (inclusive) min and max (inclusive).

old Re: random_trigger

DC
Admin On Online

Quote
1
2
3
4
5
6
7
8
9
addhook("trigger","randomtrigger")
function randomtrigger(trigger)
	if trigger=="myrandomtrigger" then
		rv=math.random(1,3)
		if rv==1 then parse("trigger entity1name") end
		if rv==2 then parse("trigger entity2name") end
		if rv==3 then parse("trigger entity3name") end
	end
end

save in your maps folder with the name of your map and the extension ".lua" for example when your map is called "mymap.map" you have to save it as "mymap.lua" in the same folder. cs2d will automatically load it when you load your map then.

it will trigger "entity1name", "entity2name" OR "entity3name" as soon as you trigger "myrandomtrigger"

I did NOT test this script!
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview