A stand alone application! (CountDown) ?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

A stand alone application! (CountDown) ?

Started by kepp, 15 December, 2003, 14:33:11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kepp

That is possible and very easy todo.

With 10 lines of codes in VB you can launch
A LUA script in PtokaX Script folder, and then, in that lua file, At serving start, or on a timer
SendToAll(Bot, "MERRY CHRISTMAS")
...
The biggest issue however is the button "Restart Script"
as i don't know, and i don't think there's a way todo so via a stand alone application...

SO my question is, if there's someone in here that knows Vb well and perhaps know a good way to do so...
(If possible)
Guarding    

c h i l l a

dunno if  got you right but you want a vb script that restarts your scripts for you??  correct?
or you only want a Lua script with a timer?

kepp

#2
Nope.... You see, I know LUA and i know basics in VB.
In VB i've made myself a little application, An Invinsible Timer that is.
Now with that i can set date/time so it will start to countdown to that date/time and when it hit that date/time it will launch a LUA file. With that i can use that as a countdown for diferent things! Etc: New Years Eve

Problem is, when it lauch the LUA file, Ptokax won't Restart the script automaticaly.
And therefore it won't work.. :(

However, You mentioned a timer, so Would it take much
performance if i make a a timer in lua, let's say every half a sec to restart scripts?
and will that cause any problems for others script im running?
Guarding    

c h i l l a

every half a second,  is quite often, but it depends on what you do when the timer triggers,
 some numbers...

for exsample to run through a 1 million big table you need with foreach(function 12 seconds around) depending on the processor.

so you can't do that in half a seond,  but
if its something like  i = i +1 then it shouldn't bother actually.

but I suggest to have a timer in a LUA script.. and if you take the new years count down for exsample,  there the timer is duno 1 hour I thin and when getting nearer to newyears eve it trigger more often...

kepp

hmm, i don't know if you understood me right...

I don't want a lua script to do the countdown for me...

all i want to know is if it will take much performance and if it will cause any probelsm using other script if i use a timer in LUA to restart the script/s Automaticaly....

just like i type !restartscript
A timer on that i mean, then that would solve my problem and i can continue making that application!

Thanks
Guarding    

c h i l l a

no I actually  think a LUA timer is the best to restart sciripts.  but every half a second...   well just try it.., but a lua timer is better.. cause then you need no extra proggie.

kepp

#6
Yes i know, and i wouln't have have started making one unless i couln't add More Countdowns, Advertising in your hub, etc etc etc

And how would it be done to restart scripts on a Lua Timer?
Guarding    

[NL]trucker

kepp

if i get you right

a: you have a vb scripts that trigers a lua script .

on this question :The biggest issue however is the button "Restart Script"
as i don't know, and i don't think there's a way todo so via a stand alone application...

ofcours in lua you can restartscripts with no prob at all

i,m not a lua hero but i think it is something like this

if a=b then !restartscripts
you even can make it so that it only restart 1 or more scripts i think

like
if a=b then !restart xxxxxxx.lua

or you will have to direct the lua script back to look in the vb script and have it look there to see if a variablle is matched so it triggers the lua script again .

or the other way around to have the vb to look at the lua file and after firing the lua file it  automatticly starts again

so you will need the command put in your lua file to automatticlly restart scripts after finishing the first part of the script

but if thats possiblle i dont know cause lua and visual are two diffrent scripts.

hope i,m right with this if not please let me know.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


turkiye

QuoteOriginally posted by [NL]trucker
kepp

if i get you right

a: you have a vb scripts that trigers a lua script .

on this question :The biggest issue however is the button "Restart Script"
as i don't know, and i don't think there's a way todo so via a stand alone application...

ofcours in lua you can restartscripts with no prob at all

i,m not a lua hero but i think it is something like this

if a=b then !restartscripts
you even can make it so that it only restart 1 or more scripts i think

like
if a=b then !restart xxxxxxx.lua

or you will have to direct the lua script back to look in the vb script and have it look there to see if a variablle is matched so it triggers the lua script again .

or the other way around to have the vb to look at the lua file and after firing the lua file it  automatticly starts again

so you will need the command put in your lua file to automatticlly restart scripts after finishing the first part of the script

but if thats possiblle i dont know cause lua and visual are two diffrent scripts.

hope i,m right with this if not please let me know.
Maybe 8)

[NL]trucker

lol

just reading the above and i realised if you have the lua script where it belongs [in scriptdir]

and you do !restartscripts it automaticlly starts all the scripts and you dont want that to happen.

you want it so that it restart just the normal scripts and not the one you want to use with the vb file
and i dont think it is possiblle to remove the script automatticly out of the scriptdir after it has done its job.

or you will have to make the vb file so that it deletes the lua file after firing and then put it back in when it is needed again
and if that is possible i dont know.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


pHaTTy

Ok i might as well let ppl know now, i am writing Gekko v5 as well as Pirate

Pirate is an external bot, you can connect to hub, i will be gonna try and get it out, b4 new year/ christmas, so i can add the countdown to it...it will send a pm to all...........

but dont tell anyone :P

LOL
Resistance is futile!

kepp

That is possible... When it has done its job you kill the file...

he he, ok, i guess i can't make myself clear here!! Lol :)

It's not a VB Script, The application, The program is made in VB 6.0.

I can on a timer copy a lua file from one destination into another, That would be Ptokax script folder...
BUT, when that's done, i need something that restart the scripts, Else it won't work untill i click on "restart script"

That's why i thought about timer with just a few lines of code that can do that Automaticaly.

then i have no other problems, i can then just add a new timer in the application with an Interval of 1400,
and then kill the file!
Guarding    

[NL]trucker

just add something like this in the last part of the lua script

if a=b then !restartscripts

i mean after it has done the job

i dont know if this is the right syntaxis for that you will have to ask a scripter.

perhaps phatty can give you the right one.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


Cruzin

Hiya all,

I am new to lua But I think I know whats wanted here!  Maybe, Perhaps even.

How about if you exturnal program just writes 1 line to a text file and replaces that 1 line with a new line whenever the line needs to be changed!  Then in your lua script all you have to do is set it to read that 1 line from the text file every X seconds. If the text file is empty then you can set the lua file to display nothing etc.

Sorry if I have got the wrong idea.

regards,

Cruzin

NotRabidWombat

"i use a timer in LUA to restart the script/s Automaticaly"

Why do you want to continuously restart the scripts? This can cause serious performance issues.

"A LUA script in PtokaX Script folder, and then, in that lua file, At serving start, or on a timer
SendToAll(Bot, "MERRY CHRISTMAS") "

As far as I can tell, you want the hub to announce to everyone Merry Christmas at specific event. Or in general, you want event A to occur at time B. It seems to me you've really overcomplicated things with the solution:
a) Move a new script file to PtokaX dir
b) Restart Scripts to exec new script
c) Move script out

The Lua timer is just as usefull for getting the time every second. Use the lua function date( [format] ) that is documented here. This way you can detect what time it is and you can simply dofile( .. ) another script or run a segment of code included in the timing script.

Now you don't have to worry about working with two seperate script files.

This solution is also applicable to any other event that you want to happen at a specific date and time. With my version I usually set the Lua timer for about 15 seconds to come pretty close to being on the minute.

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

kepp

First off i never said "i use a timer in LUA to restart the script/s Automaticaly"

I said i would like to... (That is another sentence yes)

Please understand that i am not going to to all these

"a) Move a new script file to PtokaX dir
b) Restart Scripts to exec new script
c) Move script out "

with PtokaX.... (No way) I know a better solution myself if i thought like that.

I want the "Application" to launch a lua into the script dir.
No problem, Only problem is, I've said it 4 times,
That is if any1 knows howto restartscripts on a timer...
and if it would cause problems with other bots...

I've said that before...
And thanks for answering me
Guarding    

NotRabidWombat

Ok. I understand your request that you want an application to launch a lua script. What I don't understand is why you would want to do this. What possible benifit is there to launching a script through an application that you could not already do through a lua script? That's why I presented an alternate solution.

Restarting all scripts to run may also have adverse effects. You'll lose data that isn't stored regularly. This could also interfere with other operations through scripts.

So, what is your final goal with the stand alone application?

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

c h i l l a

other solution, maybe...

you could load a LUA script with a timer function have that script,  remove your file into the script folder when you , want but actually not neccessary, cause you could call that script, by dofile(thefile)  but you can't have another timer in that script I guess..  you would need all timers in that script that is loaded by ptokax.

But you could also say what you actually want to do besides that you want to restart script by timer...
I mean what do you want to do, what effects should it have...  I bet there is a solution.

kepp

Good point... :)

I wnt the application, to have several timers (Not a LUA timer)

I also want it to perform tasks for me like the countdown i mentioned, Now belive me, i've made the application allready, and tried it, (Works absoltely fine)

However, I had to press restart scripts..
What if im not there when i want it to be performed?
Yea, there's another solution, i could just make a Big lua file..

About dofile(), yea, i could allways have a timer in the application, when that one triggers i can write a propertie in a dll file and then open it up with dofile()
BUT, Can i with lua, Compare the setting/s with dofile and do a function of that?
I don't know but i doubt it...
if you can do that you can do a stand alone LUA timer

Anyway, there may be other solutions to do what i need.
but the best solution so far is with a timer, restart scripts, once an hour or so,

This is a request  ;)
Guarding    

NotRabidWombat

"Anyway, there may be other solutions to do what i need.
but the best solution so far is with a timer, restart scripts, once an hour or so"

That's not very precise when it comes to event driven functionality. This could result in +/- 30 minutes from the actual time that you want.

My suggestion is to try to keep things simple in lua.

Write a main lua script that kicks off a lua timer that occurs every 15 seconds. Then create an event queue (you could do this through a table). Each event is the time to trigger the event and the function to run when it is time. So all you have to do in your main is scan through all the events and make sure your current time isn't greater than or equal to the event time. If it is, run the function. Write another function to add events to your event queue and you're all done. Now you have a very portable script that runs entirely in lua/PtokaX.

dofile(...) is a lua function that runs a lua file as is.

Each lua file in the scripts directory gets its own Hub Events that it can override (DataArrival, NewUserConnected, etc). Using a dofile on a lua script that has these functions will overwrite the ones in the calling script.

I hope I explained everything as well as possible. If you want to continue with your VB script alternative, you can use Tab and Ctrl sequences to get to Restart Scripts button. However, this can get really trick depending on what is in focus in PtokaX when you want to restart the scripts.
Another possibility, you could write an application that hooks into PtokaX and sends an WM_MESSAGE that the button has been pressed. This is a little more sure fire way of doing it.
Yet another alternitve is you could use a DC Client logged into the hub to send the commands "!restarscripts". This may be easier with BCDC which now has scripting of its own.

Maybe I made things worse ;-)

-RabidWombat


I like childish behavior. Maybe this post will be deleted next.

Optimus

mm, Hi all and m8 Rabid

Just a other thing...
QuoteThis may be easier with BCDC which now has scripting of its own.

Are there scripts aviable Rabid to look at or to use?

Me getting curious... :)

kepp

Nope, you just made it alot easier for me to say that BCDC has scripting support... :)
Guarding    

c h i l l a

yepp I need a exsample too, cause I can't get to work.

SMF spam blocked by CleanTalk