Relaying Script-Level Objects

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
agitated
GamingTools Subscriber
Posts: 30
Joined: Sat Apr 28, 2007 5:05 pm

Relaying Script-Level Objects

Post by agitated » Sun Feb 24, 2008 2:37 pm

I've defined an object 'pak':

Code: Select all

objectdef pak
{
  variable string Name
  variable int Number

  method Initialize()
  {
    Name:Set[Unknown]
    Number:Set[0]
  }

  method setData(string name,int number)
  {
    Name:Set[${name}]
    Number:Set[${number}]
  }

  member Name()
  {
    return "${Name}"
  }

  member Number()
  {
    return "${Number}"
  }
}

I have scripts in two sessions. One script attempts to relay an object of type 'pak' to the other. When the destination script receives the object and tries to display the passed values of members Name and Number, it only displays the initialized default values, not the passed values.

Here's the sender:

Code: Select all

#include "${LavishScript.HomeDirectory}/Scripts/controller/Libs/defines.iss"
function main()
{
  variable pak bigData
  bigData:setData["FreakDog",2010]
  echo "${bigData.Name},${bigData.Number}"
  relay is2 -noredirect Script[objtest2]:ExecuteAtom[showData,${bigData}]
}
And here's the receiver:

Code: Select all

#include "${LavishScript.HomeDirectory}/Scripts/controller/Libs/defines.iss"
function main()
{
  while (1)
    waitframe
}

atom(script) showData(pak bigData)
{
  echo "Name: ${bigData.Name}"
  echo "Number: ${bigData.Number}"
}
The receiver echoes Name: Unknown and Number: 0 instead of the passed values.

What do I have wrong?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun Feb 24, 2008 8:21 pm

relay is2 -noredirect Script[objtest2]:ExecuteAtom[showData,${bigData}]
What tihs is doing isn't passing an object -- in fact, you can't pass an object. Any time you use ${}, you are executing the final object in the sequence's ToText member -- see http://www.lavishsoft.com/wiki/index.ph ... pes#ToText -- and inserting it into the command at that position. As no ToText member is defined in your objectdef, the value isn't likely to contain anything useful. The command that probably got relayed is this:

Code: Select all

Script[objtest2]:ExecuteAtom[showData,scriptobject]

agitated
GamingTools Subscriber
Posts: 30
Joined: Sat Apr 28, 2007 5:05 pm

Post by agitated » Mon Feb 25, 2008 11:34 am

Thanks Lax!

Post Reply