DICE PACKS BUNDLE
Page 3 of 3 First 123
  1. #21
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by SilentRuin View Post
    Then magically I can access it.
    ...

    I feel I'm missing something basic - but this seems to be the only way to get access to things at this level.
    Nope, it's not "magic" that is how Global Script Packages work. They're global, their scope is global, it's not tied to any window or GUI control. So if you call MyStuff.Something (assuming MyStuff is a global script package) then you need to pass it all the information it needs to work with, for example a top level window instance or a top level database node, or whatever it needs to work with.


    Quote Originally Posted by SilentRuin View Post
    My code currently has the source coded to the controls - but you seem to forget I don't want those controls seen - nor do I want the gap I've created there - when the button is not active.
    I'm not forgetting, it's just that it's very, very, very hard to follow what you're trying to do.

    My recommendation would be to take a step back and spend some time reading documentation and learning more about script scope. Programming isn't "magic" (as you've said a few times) and expecting something to "magically" work is a recipe to failure sooner rather than later. From trying to help you in this thread it seems your approach is to flail around with code until something works. Sorry if that's not correct, but it's what it looks like. Whereas some people might get lucky with coding some simple things with that approach, it's really not a good idea. Few people enjoy reading documentation and teaching themselves, it's much for fun to write code and see it in action, but I really feel you need to take those steps to some education through reading rather than purely through trial and error.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  2. #22
    Quote Originally Posted by Trenloe View Post
    Nope, it's not "magic" that is how Global Script Packages work. They're global, their scope is global, it's not tied to any window or GUI control. So if you call MyStuff.Something (assuming MyStuff is a global script package) then you need to pass it all the information it needs to work with, for example a top level window instance or a top level database node, or whatever it needs to work with.



    I'm not forgetting, it's just that it's very, very, very hard to follow what you're trying to do.

    My recommendation would be to take a step back and spend some time reading documentation and learning more about script scope. Programming isn't "magic" (as you've said a few times) and expecting something to "magically" work is a recipe to failure sooner rather than later. From trying to help you in this thread it seems your approach is to flail around with code until something works. Sorry if that's not correct, but it's what it looks like. Whereas some people might get lucky with coding some simple things with that approach, it's really not a good idea. Few people enjoy reading documentation and teaching themselves, it's much for fun to write code and see it in action, but I really feel you need to take those steps to some education through reading rather than purely through trial and error.
    Code I'm familiar working with has no "buried" intelligence like the script packaging. What you do - is what you get. Including XML. All this "script package" stuff is additional intelligence I've never had in things I've programmed with so, yeah. Magic. Especially, when all of the documentation assumes an underlying understanding of some of these things. New to LUA - new to "global script packages". Granted code is code, but really things people assume are "standard" in their worlds are really just specialized tools they are familiar with. And the language in documentation reflects that. These script blocks are "intelligent" with "rules" and underlying logic which is not evident to simply reading the code or the examples available. And don't get me started on the examples or comments within the code.

    If it were not for helpful people like yourself, this would take forever to piece things together through documentation and existing code examples. Though that is indeed most of what I do to solve these issues.

    Now that I understand "gobal" vs "local" script calls that makes some of the "magic" in the examples I've seen where they have access and I do not simply by the method I used to access LUA code - makes it clearer.

    Thanks. I'll keep plugging away. I win in the end usually through pure perseverance. Though it may take me longer, I come out the other end with a deeper understanding having made most of the mistakes one can make.
    Last edited by SilentRuin; July 10th, 2020 at 19:47.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  3. #23
    Pure stubbornness solved it

    Thank you for being my sounding board on all this. For posterity, I record my solution.

    By simply printing out every single possible keyword from the script block, I found "self" was the only window provided (though "parentcontrol" was there also - everything else was nil).

    This was for an XML where the windowclass was buried in a subwindow.

    Gist being this bit of pretend code shows my solution to get my window to be able to call my 'global' script and play nice with everything and keep everything on host and player side looking the way it should (chunks of windows displayed - or not displayed - real time):

    This is all in the XML
    Code:
    	<windowclass name="A">
    			<subwindow name="sub_A">
    				<class>B</class>
    				<activate />
    				<fastinit />
    				<invisible />
    			</subwindow>
    		</sheetdata>
    	</windowclass>
    
    	<windowclass  name="B" >
    		<script>
    			function onInit()
    				local nodeChar = self.getDatabaseNode();
    				DB.addHandler(DB.getPath(nodeChar, "B.thing"), "onUpdate", onActiveUpdate);
    				Interface.onWindowOpened = onWindowOpened;
    				onWindowOpened(self);				
    			end
    			
    			function onClose()
    				local nodeChar = self.getDatabaseNode();
    				DB.removeHandler(DB.getPath(nodeChar, "B.thing"), "onUpdate", onActiveUpdate);
    			end
    			
    			function onActiveUpdate(nodeActive)
    				ManagerThing.BActivated(self);
    			end
    			
    			function onWindowOpened(w)
    				local sClass = w.getClass() or "";
    				if sClass ~= "A" then 
    					return; 
    				end
    				ManagerThing.BWindowManipulationStuff(self);				
    			end			
    		</script>
    And I had access in my ManagerThing to all my controls by self.[control name] and could do whatever anchor or visibility stuff I wanted. And it instantly happened on player side when host hit button.

    Huzzah for snipes!
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  4. #24
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Great!

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in