Page 1 of 1

Access field in a card from script only stack

Posted: Mon Apr 13, 2020 3:45 pm
by foosmaster
I have a library stack which handles web services calls/events
I get an event from the server in the script only stack, and I want to update a field in the currently active card.
basically this happens as a result of async load URL <> with message "GameEvent"
then in GameEvent I want to update the player name, I know the card name, I know the label's name, i tried:

Code: Select all

set text of field "player1name" to pname
no luck, I tried this

Code: Select all

set text of field "player1name" of card "declare" to pname
still no luck, I keep on getting
stack "GuiController": execution error at line 58 (Chunk: can't find card), char 17
<< I wanted to put an image - but it seems I can't :( >>

of course this isn't the stack the card "declare" is included in.

do I need to use the card in a special way from the stack ?

Re: Access field in a card from script only stack

Posted: Mon Apr 13, 2020 4:36 pm
by richmond62
ОК: to be honest I've never worked with a script-only stack, BUT I should imagine
that calling a field on another stack from a script-only stack is exactly the same
as calling a field on one stack from another.

Let us imagine for a moment 2 stacks called "mStack" and "sStack" for 'main stack' and 'sub stack' respectively.

Now let us suppose there is a script in stack "mStack" that wants to get some information out of a field on stack "sStack",
one might have a script of this sort:

Code: Select all

put fld "dataIneed" of card "KARD" of stack "sStack" into fld "gottit" of card "homeCard" of stack "mStack"
or, similarly:

Code: Select all

put fld "dataIneed" of card "KARD" of stack "sStack" into GOTTIT
Now . . . for some odd reason I would suppose a script-only stack has no cards and no controls so ALL you might be doing is calling functions.

Code: Select all

do "on crazyFunction" of stack "sStack"
Or, the other way round [from a script-only stack]:

Code: Select all

put DATAiNEED of stack ""sStack" into fld "gottit" of card "homeCard" of stack "mStack"

Re: Access field in a card from script only stack

Posted: Mon Apr 13, 2020 5:09 pm
by FourthWorld
Hard to say for sure without seeing the full context, but when a card can't be found and you know it exists in a certain stack, including the stack name in the object reference will resolve that ambiguity.

Re: Access field in a card from script only stack

Posted: Mon Apr 13, 2020 7:45 pm
by foosmaster

Code: Select all

of stack "mStack"
did the trick, thanks a lot :)