HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] what can be made a stateful object?  (Read 1743 times)

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
[Resolved] what can be made a stateful object?
« on: Jun 09, 12, 05:32:58 AM »

Hi

We want to set up a stateful object (1) which will act as a 'proximity alarm' for another stateful (2) object so when the player approaches stateful object 2 stateful object 1 will trigger a state change in object 2.

We have looked at using triggers with the TriggerEnter event setting the state but this always throws an error in function 'queryAssociation' definition not found '_StateRootAssoc'.  The TriggerEnter code is included in the class methods for a class which includes _StateRoot as a parent class.

The error is being generated when we try and use the $STATES system node functions...

In trying to circumvent the problem we were wondering if it would be possible to simply set the Trigger up as a stateful object but can't seem to 'Link' the State to the Trigger...

Ideas please?

Thanks
« Last Edit: Nov 03, 12, 09:13:30 PM by HE-Cooper »
Logged

Stranger66

  • World Owners
  • ****
  • Posts: 26
    • View Profile
Re: what can be made a stateful object?
« Reply #1 on: Jun 10, 12, 05:58:12 PM »

I think I found the solution at this problem:

Code: [Select]
Error:
!ERROR!System:SCRIPT ERROR: Exception DefinitionNotFoundException in Function "queryAssociation" definition nor found _StateRootAssoc

Call Trace:
      Script _StatesClassMethods lime 216 me(id=1000000799 class=_States)
      Script _StatesClassMethods lime 317 me

The field "_StateRootAssoc" exists as an Association on the server

in "_StatesClassMethods"
Code: [Select]
  areaRoot as NodeRef of Class AreaRoot = GetRootNode()

  foreach a in QueryAssociation(areaRoot, "_StateRootAssoc", 0)
    if a.target is kindof _StateRoot
      StateRoot = a.target
      break
    .
  .

areaRoot as NodeRef of Class AreaRoot return an Error in a client script not in server script

if we call $STATE by a client script, this may cause trouble.

EDIT:

Confirmation: Some _StateClassMethods functions are only available in server script, just like AreaRoot (a class server) in not found in database for client script

Code: [Select]
      areaStates as NodeRef of Class _StateObjects = $STATES._GetStatesNodeByClass( "_areaStates")
Works fine in server script and don't works in client script.

Explication: the external function QueryAssociation exists on server AND client side but the field "_StateRootAssoc" exists only on server side. If you call $STATES._GetStatesNodeByClass (by example) in a client script, $STATES._GetStatesNodeByClass will call  _GetStateRoot() who calls QueryAssociation(areaRoot, "_StateRootAssoc", 0) and as "_StateRootAssoc" don't exists on client side an error occurs.

We can use : "call server <a ScriptRef>:<a function>(<arguments>) [[optional failure clause]]" to call the server script executing the $State functions (function must be untrusted).
« Last Edit: Jun 10, 12, 07:34:55 PM by Stranger66 »
Logged

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: what can be made a stateful object?
« Reply #2 on: Jun 11, 12, 07:20:11 AM »

Much thanks Stranger66,

That describes the issue perfectly.  We need the Trigger to be client side for subsequent functions but need to do a call to a server side script to perform the server $STATE functions.

 :-\
Logged

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: what can be made a stateful object?
« Reply #3 on: Jun 11, 12, 04:28:33 PM »

Good investigation, and information, and per Jay _StateRootAssoc is not defined on the client. Which is broken. So we will have to do some crazy things to fix it for you before later deploys fix it. Jay will follow up.
Logged

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: what can be made a stateful object?
« Reply #4 on: Jun 12, 12, 03:54:59 AM »

Thanks Cooper,

I think we have hit on another issue as well - please see other post re the Triggers?  Here: https://community.heroengine.com/forums/index.php/topic,2779.0.html

Cheers

Cas
« Last Edit: Jun 12, 12, 04:06:37 AM by Tgames »
Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: what can be made a stateful object?
« Reply #5 on: Jun 12, 12, 10:16:40 AM »

You guys have correctly identified an omission in the current version of script distributed with HeroCloud. We've corrected the issue for the next package release, but - until then - here's how you can restore access to the client-side methods that are throwing script errors:
  • Create a new association definition in the client DOM named 'E_StateRootAssoc' and give it the properties 'Unique=yes', 'Unique Source=yes', 'Unique Target=yes' and 'Hardness=soft'
  • Change line 216 of client-side script '_StatesClassMethods' to read 'foreach a in QueryAssociation($STATES, "E_StateRootAssoc", 0)'
  • Change line 228 of client-side script '_StatesClassMethods' to read 'AddAssociation($STATES, "E_StatesRootAssoc", StateRoot)'
  • compile and submit

When the next package release is distributed, the script will be overwritten with our new version and a definition for _StateRootAssoc will be created. This will maintain the above patch permanently.

Please Note: It's important that you do 'not' create a definition for _StateRootAssoc on your own, as this will conflict with any future update we make to the system; please use the name E_StateRootAssoc and modify the script mentioned above.

Hopefully this will solve any issues with client-side area state scripts; if not, feel free to follow up.
Logged

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: what can be made a stateful object?
« Reply #6 on: Jun 12, 12, 10:52:36 AM »

Thanks Jay, changes done: we will give it a go now.
Logged

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: what can be made a stateful object?
« Reply #7 on: Jun 12, 12, 11:46:26 AM »

We are clear of the _stateRootAssoc problem but have another issue:

The sample code at the bottom of the States System page http://wiki.heroengine.com/wiki/States_System has a line
GLOMClass("_statefulObject", statefulObject )

We are getting definition not found against the _statefulObject class.  I have looked for the class in the client DOM editor and can't find it... there's _stateobject though.  _statefulObject exists server side according to the DOM.

Also, when I was playing with creating a StateAction I noticed that the method $STATES._StatesObjectCreateStatePlayFx didn't exist (client side again). 


Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: what can be made a stateful object?
« Reply #8 on: Jun 12, 12, 05:02:32 PM »

The current implementation of area states only allows for the creation and modification of area states on the server.  While code does exist on the client to create nodes which reflect data about the server-side states, you cannot create an area state on the client by hand. It sounds like what you want to do is create your area state on the server, create a trigger or some other mechanism which will toggle your state, and then make a call on the server to modify the state object.

All tutorials, example code and demo code that make use of area states are exclusively on the server.
Logged

Tgames

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: what can be made a stateful object?
« Reply #9 on: Jun 13, 12, 04:18:30 AM »

Thanks Jay,

I think your explanation could happily be adapted and added to the wiki page for the States System for clarity.

We will try this out now.

Logged