This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Feature Updates
 Completed Requests
 [COMPLETE] sp_init()
 Forum Locked
 Printer Friendly
Author  Topic Next Topic  

plunt

Italy
88 Posts

Posted - 12/25/2012 :  04:17:39  Show Profile
add to "Global Lua" a
function sp_init()
to execute code at fist start after initialitation.
f.e. if i insert
acSetProcessPriority(acFindWindow("STROKESPLUS"), nil, nil, 0x00000020)
in the "Global Lua" it not work at start because it is reinitialized.

Edited by - plunt on 12/25/2012 05:52:22

Rob

USA
2615 Posts

Posted - 12/25/2012 :  18:29:40  Show Profile  Visit Rob's Homepage
This seems like a reasonable thing to add =)
Go to Top of Page

Rob

USA
2615 Posts

Posted - 12/26/2012 :  10:01:54  Show Profile  Visit Rob's Homepage
Instead of a new function support, which I don't think is necessary here, I'm moving the Lua init code to be called after all S+ initialization is complete in 2.4.6.

So your code above would work fine, so would the tray icon toggle call...which are really the reasons you're requesting this feature, I believe.
Go to Top of Page

plunt

Italy
88 Posts

Posted - 12/26/2012 :  18:08:54  Show Profile
quote:
Originally posted by RobSo your code above would work fine, so would the tray icon toggle call...which are really the reasons you're requesting this feature, I believe.


acToggleTrayIcon()
not seem to work at startup.

If i use:
acMessageBox("1","2",0)
acToggleTrayIcon()

the icon appear and show messagebox
click
the icon disappear and show messagebox
click
the icon reappears

it seems that the startup code is executed twice.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 12/26/2012 :  19:40:33  Show Profile  Visit Rob's Homepage
Heh, yea there are actually two Lua states which are initialized, so it does make sense. I'll have to think about how to handle this type of use case.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 12/26/2012 :  23:16:16  Show Profile  Visit Rob's Homepage
Ok, sp_init() is needed because of the dual Lua states; added in patch 2.4.7.

sp_init() will ONLY be called from Lua state 1. What this means is you shouldn't use sp_init() for anything which you want initialized/defined/called in both Lua states...only stateless/non-persistent code should be used here.

This post explains the Lua states:

http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=435

Also note that when you click Apply or OK in the Settings window, both Lua states are re-initialized. This means that sp_init() will be called again...and if you click Reload Config and Lua Engine from the tray icon.

I've also updated acToggleTrayIcon to accept a parameter:
-1 : Hide icon
0  : Toggle icon (same as passing no parameter)
1  : Show icon

So if you call acToggleTrayIcon(-1) and the tray icon is already hidden, nothing will happen.
Go to Top of Page

nober

29 Posts

Posted - 11/12/2020 :  05:03:24  Show Profile
Out of curiosity, is there something along the line of
sp_exit()
?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 11/12/2020 :  09:12:13  Show Profile  Visit Rob's Homepage
I don't believe so. I skimmed through the source code for the unhook/unload functions and don't see anything that looks like it calls any Lua on exit.
Go to Top of Page

nober

29 Posts

Posted - 11/12/2020 :  14:16:43  Show Profile
I see, thanks for looking up. I added the following to the bottom of global lua tab.

function sp_exit()
	-- this code is executed after manual calling  :p
end
Go to Top of Page
   Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000