Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Object referencing  (Read 3064 times)

0 Members and 1 Guest are viewing this topic.

raychaser

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
    • View Profile
Object referencing
« on: August 16, 2007, 05:15:40 PM »

Having trouble phrasing my question. Maybe I'll give an example.

An script I have gets passed a string which corresponds to the name of an actor in a particular scene. This may be the main actor or an NPC. I want to take that string and from it find the actor's X and Y coordinates. Sounds simple...

As I see it this involves two problems:
  • How do I reference an actor object given only a string corresponding to the object name? I believe standard javascript can do something like this[str] or document[str] but I'm not sure if that is possible here.
  • Is it possible to find actors based on the scene that they are in like scene[actor] or something? The reason I ask is that each scene will have different actors and I don't want to have to declare ALL of them as global variables in every script or in global.inc since there will likely be a lot of them and keeping track of them in multiple places is a pain. The NPCs will be defined in scene_init.script for each scene but the function I'm trying to use is located in the root scripts location.

Does this make any sense?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Object referencing
« Reply #1 on: August 19, 2007, 12:06:26 PM »

You'd need to store the actors in some array, if you want to enumerate them later. You could even store them under their name, something like:

actors_array["joe"] = Game.LoadActor("path\joe.actor");
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.025 seconds with 20 queries.