A question for the Moho developer(s).
There are some undocumented classes that are used in some places but don't have any information available in the pkg files. They are: LM_Cursor, LM_Path, LM_Image.
Is there a chance we could get some information on those?
Thank you!
Undocumented LM classes
Moderators: Víctor Paredes, Belgarath, slowtiger
Undocumented LM classes
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
- Lost Marble
- Site Admin
- Posts: 2347
- Joined: Tue Aug 03, 2004 6:02 pm
- Location: Scotts Valley, California, USA
- Contact:
Re: Undocumented LM classes
Yes, I think I can do that. I'm a little swamped with other things, but here's a quick answer off the top of my head:
These are internal C++ classes that may not have been intentionally exposed to Lua.
LM_Path represents a path to a file or directory on disk. In the Lua interface, we try to expose these as plain strings, that then get translated straight into Lua strings. I think LM_Path is referenced in the Lua pkg files, but not actually fully exposed. For example, in the M_Material3D class, there's this function:
LM_Path& GetTexturePath( LM_SecureAccess **outAccess = NULL );
But I don't think you can use LM_Path from Lua. It should look more like this other function:
void SetTexturePath( const char *path, LM_SecureAccess *copyFromAccess = NULL );
There is uses a plain string that can be accessed from Lua.
LM_image is a low-level image object in the C++ code. I think the only place it gets used in the Lua code is in the LM_Button::SetImage function, which was probably not meant to be exposed to Lua. It would let you change a button's image on the fly. We can enable that abilitym but instead of a raw image object, we would probably let Lua do it by specifying the file path of the image.
Finally, LM_Cursor lets you create a mouse cursor, and you can assign it to a view (typically the canvas). You can create an LM_Cursor from a PNG image by specifying the file path to the PNG, and the coordinates of the cursor's "hot spot".
These are internal C++ classes that may not have been intentionally exposed to Lua.
LM_Path represents a path to a file or directory on disk. In the Lua interface, we try to expose these as plain strings, that then get translated straight into Lua strings. I think LM_Path is referenced in the Lua pkg files, but not actually fully exposed. For example, in the M_Material3D class, there's this function:
LM_Path& GetTexturePath( LM_SecureAccess **outAccess = NULL );
But I don't think you can use LM_Path from Lua. It should look more like this other function:
void SetTexturePath( const char *path, LM_SecureAccess *copyFromAccess = NULL );
There is uses a plain string that can be accessed from Lua.
LM_image is a low-level image object in the C++ code. I think the only place it gets used in the Lua code is in the LM_Button::SetImage function, which was probably not meant to be exposed to Lua. It would let you change a button's image on the fly. We can enable that abilitym but instead of a raw image object, we would probably let Lua do it by specifying the file path of the image.
Finally, LM_Cursor lets you create a mouse cursor, and you can assign it to a view (typically the canvas). You can create an LM_Cursor from a PNG image by specifying the file path to the PNG, and the coordinates of the cursor's "hot spot".
Re: Undocumented LM classes
Yeah, that would be a really nice to have feature! Image buttons are compact and attractive, and having the ability to change their visual state on the fly would greatly increase their potential. Text buttons tend to consume too much real estate.Lost Marble wrote: ↑Sun Jan 31, 2021 8:09 pm We can enable that abilitym but instead of a raw image object, we would probably let Lua do it by specifying the file path of the image.
As for the LM_Path, as far as I remember, there was a case when one of my friends was working in a team of remote people and some of them were using PCs and others were using Macs. So there was a problem using referenced layers because the paths were different. So they tried to create a script to change the reference path and were unable to do that because the LM_Path is not exposed.
So, if possible, please consider some improvements in this area, they would be really appreciated.
Thank you Mike!
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
Re: Undocumented LM classes
@Stan: I couldn't express it better...Stan wrote: ↑Sun Jan 31, 2021 8:52 pmYeah, that would be a really nice to have feature! Image buttons are compact and attractive, and having the ability to change their visual state on the fly would greatly increase their potential. Text buttons tend to consume too much real estate.Lost Marble wrote: ↑Sun Jan 31, 2021 8:09 pm ...we would probably let Lua do it by specifying the file path of the image.
@Mike: PLEEEASE
BTW, I ended up here because I'm trying to feed an ImageButton's path argument with a path into a Moho installation directory (concretely this one: "C:\Program Files\Moho\Resources\Images\group_type"), but all I get is a Missing resource image alert no matter what I try. I think I've tried any possible back/forward slash variations, with or without extensions, relative path from "C:\Program Files\Moho\Resources\Support\Scripts\ScriptResources" like "../../../Images/group_type", but nothing...
Do you think this is even possible? I mean, to try to access from a script (in this case a Layer Script) to this kind of resources, or for security reasons or whatever you are not allowed to reach anything outside the ScriptResources folder? And lastly, if that was the case, do you know by chance if class LM_SecureAccess could (somehow) be of any help on this? Thanks!
...
Re: Undocumented LM classes
OK, I finally got it to work! I'd have never said, but this seems to be the expected relative path construction ImageButton's path argument understand: "ScriptResources/../../Images/group_type". Cool! And good to know...
...
-
- Posts: 68
- Joined: Thu Jan 24, 2019 3:52 am
Re: Undocumented LM classes
Hi, I was testing the SetImage() function.Stan wrote: ↑Sun Jan 31, 2021 5:35 pm A question for the Moho developer(s).
There are some undocumented classes that are used in some places but don't have any information available in the pkg files. They are: LM_Cursor, LM_Path, LM_Image.
Is there a chance we could get some information on those?
Thank you!
But it doesn't work properly.
It doesn't change the image of the button, could you please explain me why?
I have tried it with the path directly "ScriptResources".
also with the full path of the .png image.
and nothing
-
- Posts: 68
- Joined: Thu Jan 24, 2019 3:52 am
Re: Undocumented LM classes
Hi Ramon - specifically how does the SetImage() work ?Ramón López wrote: ↑Tue Oct 11, 2022 1:57 pm OK, I finally got it to work! I'd have never said, but this seems to be the expected relative path construction ImageButton's path argument understand: "ScriptResources/../../Images/group_type". Cool! And good to know...
Please could you explain it to me?
- synthsin75
- Posts: 9984
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Undocumented LM classes
Like Mike said above, you can't actually set LM_image, because that's a C++ object. So for scripting access, that function just doesn't work.bbrraayyaann wrote: ↑Fri Nov 11, 2022 4:50 pmHi Ramon - specifically how does the SetImage() work ?Ramón López wrote: ↑Tue Oct 11, 2022 1:57 pm OK, I finally got it to work! I'd have never said, but this seems to be the expected relative path construction ImageButton's path argument understand: "ScriptResources/../../Images/group_type". Cool! And good to know...
Please could you explain it to me?
What you can do is use LM.GUI.ImageButton, but it's hard to change the image. You have to do something to make Moho reevaluate the tool's options (like entering/exiting frame zero, changing layers, etc., that would normally allow the script to gray-out GUI elements). See my switch icons script for an example.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Undocumented LM classes
Hi. What I got work there was simply to can access images in the installation folders with the intention of reusing them in some of my buttons in mind, but nothing else... Unfortunately, what Wes says is right, we never got enough Lua powers to can really change image button's images on the fly as one could expect for the LM_Button:SetImage() method, and the only way nowadays would pass for resorting to workarounds, although not without limitations.bbrraayyaann wrote: ↑Fri Nov 11, 2022 4:50 pmHi Ramon - specifically how does the SetImage() work ?
Please could you explain it to me?
Sorry if I gave you false hope on this cause I know exactly what it feels, bro
...