Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Replace actorA with actorB  (Read 9187 times)

0 Members and 1 Guest are viewing this topic.

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Replace actorA with actorB
« on: September 14, 2011, 01:20:47 PM »

Hi
I have a small problem that is not how to solve.
Should I replace an actor after wearing a dress. To make myself understood. This actor is wearing a vest and I have to change the ActorA (without vest) with actorB with the vest in the scene when is used this dress..

I put this code in game.Script

Code: [Select]
/ / Load our main actor
if (! gDress == true) Game.LoadActor3D actor = ("actors\actorA.act3d");

if (gVDress == true) Game.LoadActor3D actor = ("actors\actorB.act3d");
Game.MainObject = actor;

gDress is true when actorA use the dress gDress=true.

I need this for when I change the scene to figure out what to load.

After I put this code in the itemVest:

Code: [Select]
on "LookAt" / / basically the right mouse button
{
Game.Interactive = false;
gDress = true;
actor= Game.LoadActor3D ("actors\actorB.act3d");
actor.Talk ("Perfect.");
Game.DropItem ("Dress");
Game.Interactive = true;
}

Now  when I use the object dress  the ActorA is blocked but visibile and remains in the scene while the attoreB is created at a point random where cant move. Changing scene, the actorA is positioned random position seems and actorB correctly  moves and other only that the actorB do not produce any scrolling in the scene.

I wish that using the vest the actorB replace istant actorA for the rest of the game or until you change the variable to false gDress.

I hope I was clear.
Thank you.
« Last Edit: September 15, 2011, 08:55:21 AM by keybone »
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Re: Replace actorA with actorB
« Reply #1 on: September 14, 2011, 04:27:44 PM »

i'd like to know this too !
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Replace actorA with actorB
« Reply #2 on: September 14, 2011, 07:52:28 PM »

You are loading an entirely new actor, It doesn't know anything about the old actor. So simply remember the position of the old one (in some variables) and after calling LoadActor set the position of the new actor.
Also, don't forget to unload the old actor first! Or it will stay loaded in memory.

As for scrolling, you need to tell the game which actor should be tracked by the "camera".

Game.MainObject = newActor;

I'm afraid the change will never be *instant* though, loading the actor takes some time. Various games solve this problem with some tricks, such as the character walks to some hidden place and gets back in a new dress (i.e. the new model is loaded while the character is hidden).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Replace actorA with actorB
« Reply #3 on: September 15, 2011, 09:03:15 AM »

mm try with your tips..tk for the moment :)
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Replace actorA with actorB
« Reply #4 on: September 15, 2011, 03:16:04 PM »

why when i use this conde in game.script

// load our main actor
if (gdess==true)
{
actor = Game.LoadActor3D("actors\ActorA.act3d");
Game.MainObject = actor;
}
if (gdess==false)
{
actor = Game.LoadActor3D("actors\ActorB.act3d");
Game.MainObject = actor;
}

and set gdress at true dont load nothing?

if i set if (!gdess==true) load ActorB.. with gdress set true.   :'( :'( :'(
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Replace actorA with actorB
« Reply #5 on: September 16, 2011, 06:54:48 AM »

Well it should work, although one could write it more elegantly:

Code: WME Script
  1. if (gdess)
  2. {
  3.   actor = Game.LoadActor3D("actors\ActorA.act3d");
  4. }
  5. else
  6. {
  7.   actor = Game.LoadActor3D("actors\ActorB.act3d");
  8. }
  9. Game.MainObject = actor;
  10.  


If you want to know what's going on in there, just throw in some Game.Msg() calls.

Code: WME Script
  1. Game.Msg("before change, gdess = " + ToString(gdess));
  2.  
  3. if (gdess)
  4. {
  5.   Game.Msg("changing to actor A");
  6.   actor = Game.LoadActor3D("actors\ActorA.act3d");
  7. }
  8. else
  9. {
  10.   Game.Msg("changing to actor B");
  11.   actor = Game.LoadActor3D("actors\ActorB.act3d");
  12. }
  13. Game.MainObject = actor;
  14.  
  15. Game.Msg("after change");
  16.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Replace actorA with actorB
« Reply #6 on: September 16, 2011, 09:10:28 AM »

tk  for the code..is better.. ::rock but dont work  >:D

for the msg need a sleep for view but with a sleep there are a lot of error becouse dont find the actor soon.
but

I now do understand becouse it dont works, if i put the variable in a gDress in a scene.init = true or false or 1 (i have try a lot of diffente variable) the variable is processed after it appears the actor, while putting it in the beginning of the code  game.script processes first of the actor. I think.

mm what can I do?
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Replace actorA with actorB
« Reply #7 on: September 16, 2011, 09:19:56 AM »

You didn't actually explain what exactly you want to achieve. *When* do you want to change the actor? You're mixing together scene change, game starting, the actor changing his vest... I can't help you if I don't know what your goal is and I don't understand it from your descriptions.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Replace actorA with actorB
« Reply #8 on: September 16, 2011, 09:35:29 AM »

y sorry , my english is bad..  :'(

my goal for the moment is  if gDress= true (actor equip the dress) that when load the scene need load the actorB with dress (actorB), if gDress is false or null load actorA. Only this. :)

for convenience and for test I put the variable gDress set at true  the beginning of a scene. Then of course I'll put on the dress of the inventory.

and with the variable  set at true put in the scene.init dont work..however, if I put gDress at begin the your code in game.script work perfectly.

Code: [Select]
Game.Msg("before change, gdess = " + ToString(gdess));
gDress=true;
if (gdess)
{
  Game.Msg("changing to actor A");
  actor = Game.LoadActor3D("actors\ActorA.act3d");
}
else
{
  Game.Msg("changing to actor B");
  actor = Game.LoadActor3D("actors\ActorB.act3d");
}
Game.MainObject = actor;
 
Game.Msg("after change");

tk :)
« Last Edit: September 16, 2011, 09:41:44 AM by keybone »
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Replace actorA with actorB
« Reply #9 on: September 16, 2011, 10:49:08 AM »

So where (in which script) are you setting the variable and where is the actor switching code?

If gDress is a global variable, and you set it anywhere, and if you put the actor switching code to scene_init.script of that particular scene, it must work (when you enter the scene).

Also, as I said before, don't forget to unload the old actor before loading the new one.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Replace actorA with actorB
« Reply #10 on: September 16, 2011, 02:14:18 PM »

i put the gDress=true at begin after #include "scripts\base.inc"
 in scene_init.script and load this scene with option (set as Startup Scene (debug only).

the variable is loaded in this way:

in base.inc

Code: [Select]
#include "scripts\const.inc"
#include "scripts\variable.inc"

global Scene;
global Keyboard;
global actor;

actor.Interactive = false;

Scene.ScrollSpeedX = 1;
Scene.ScrollPixelsX = 5;

this script load variable.inc (into there are all variables of the game and there is the line : global gDress; )

anyway tk for the help :)
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Replace actorA with actorB
« Reply #11 on: September 16, 2011, 02:32:11 PM »

Soooo.... you're setting the variable to true in the include file? That would mean it's set to true every time any script starts. Probably not what you want.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Krosad

  • Anate Studio
  • Occasional poster
  • **
  • Karma: 2
  • Offline Offline
  • Gender: Male
  • Posts: 97
  • anatestudio.com
    • View Profile
    • Anate Studio Web site
Re: Replace actorA with actorB
« Reply #12 on: October 09, 2011, 07:50:34 PM »

How to unload the old actor before loading the new one?
Logged

jackslawed

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 23
    • View Profile
Re: Replace actorA with actorB
« Reply #13 on: October 10, 2011, 03:16:47 AM »

I did something similar to this, I think... had a clothing change using a different actor. I did initially have the problem of both actors loading, fixed it with:

Code: [Select]
         Game.UnloadObject(actor);
actor = Game.LoadActor3D("actors\actorB\actorrB.act3D");

(to switch from actorA to actorB)
That might not be helpful, I'm not entirely clear on what you are trying to do, but it worked for me! Just watch the load time...
Logged
 

Page created in 0.145 seconds with 24 queries.