Forum

> > CS2D > Scripts > trigger_delay : sec to ms
Forums overviewCS2D overview Scripts overviewLog in to reply

English trigger_delay : sec to ms

11 replies
To the start Previous 1 Next To the start

old trigger_delay : sec to ms

hacked
User Off Offline

Quote
Sometime ago, user Apache uwu has posted about changing sec values in trigger_delay to ms values, which is super duper useful. But after a new round, the freetimer function seems to "pierce" to trigger_start. I mean pierce is that right after the trigger_start triggers the trigger_delay, that is when the freetimer function called. I need help in resetting the trigger_delay after a new round without letting it "pierce" through trigger_start.

Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("triggerentity","_triggerentity")

function _triggerentity(x,y)
     if entity(x,y,"typename")=="Trigger_Delay" then
          timer(entity(x,y,"int0"),"parse","trigger \""..entity(x,y,"trigger").."\"")
          return 1
     end
end

addhook("endround","_endround")

function _endround()
     freetimer()
end

I make a new thread because I'm avoiding necro-posting.

old Re: trigger_delay : sec to ms

VADemon
User Off Offline

Quote
If you still have the issue, please send me a test map, because I didn't really change the freetimer() functionality

Testmap: (press the red button)
https://dl.dropboxusercontent.com/u/53753604/web/uploads/unrealsoftware.de/380385/test.map

Script: >

https://dl.dropboxusercontent.com/u/53753604/web/uploads/unrealsoftware.de/380385/millisecond_delay_trigger.lua
To install: either put it into /lua/autorun/ folder (recommended) or link it to your map (link)

The upper explosion is set to 100ms with the script, the bottom one is set to 2s with CS2D trigger_delay functionality.

It works for me ONLY when I restart round with command "endround". When I join the game through "New Game" the upper explosion isn't triggered, because the map isn't initialized to that moment (my guess).

∗ Changed:
[LUA] Function namespace
[LUA] freetimer() doesn't break other scripts which use timers that started before end of round
[TRIGGER_DELAY] You trigger name has to end with "_ms" in order to work with millisecond values. This way we don't break existing trigger_delays which work with full seconds
edited 1×, last 18.10.14 05:49:31 pm

old Re: trigger_delay : sec to ms

DC
Admin Off Offline

Quote
@user hacked: And your reply doesn't work either that way. Please describe the problem. What exactly do you do, what exactly happens? Any error messages in the console?

Without that your post is totally useless.

old Re: trigger_delay : sec to ms

KimKat
GAME BANNED Off Offline

Quote
@user hacked: Okay, you basically want to trigger something with Lua script or do you want to trigger something with a delay in milliseconds (or both)? I'm confused.

old Re: trigger_delay : sec to ms

VADemon
User Off Offline

Quote
user hacked I've posted a test map for, obviously, testing purposes. Does it work for you? Did you install the script?

UPD: Check out the script, I edited it to print text to console when it's done loading.

old Re: trigger_delay : sec to ms

hacked
User Off Offline

Quote
@user KimKat: This script basically makes seconds delay in trigger_delay to miliseconds.

trigger_start -> trigger_delay -> resettimer function called.

It was supposed to be like this:

resettimer function called -> trigger start -> trigger_delay.

Duh, I suck in explaining stuff like this.

old Re: trigger_delay : sec to ms

KimKat
GAME BANNED Off Offline

Quote
@user hacked: Ok so you want to trigger something in milliseconds instead of seconds is what I assume.

Well you could try experimenting with the hooks and stuff in CS2D and see if you could get it to work somehow. I haven't used the timer functions a whole lot but I have used them at times and gotten them to work rather easily.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function action(parameter)
	parse('sv_msg "'..parameter..'@C"')
	freetimer(action,parameter)
end

addhook("trigger","ontrigger")
function ontrigger(trigger,source)
	if(trigger=="trigger_name" and source==1)then
		-- If trigger_name is triggered by Lua script.
		timer(100,"action","Hello world!")
		return 0
	elseif(trigger=="trigger_name" and source==0)then
		-- If trigger_name is triggered by map.
		return 1
	end
end

Maybe you could try something like this and see if something happens. You will also have to place a entity for example a button on the map called "trigger_name" without quotes and whenever you press the button the hook will act upon the entity itself whenever the button press occurs. In theory that is. I haven't checked if it works or not but I assume this is what happens.

old Re: trigger_delay : sec to ms

VADemon
User Off Offline

Quote
user hacked I'm asking you for the last time to answer my questions above. "It doesn't work" isn't helpful at all.
Additionally, you can make a test map for me so I can see it in-game myself.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview