Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: "variable 'new_actor' is referenced but not defined"  (Read 329 times)

0 Members and 1 Guest are viewing this topic.

futurama140

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
"variable 'new_actor' is referenced but not defined"
« on: January 28, 2017, 09:47:51 AM »

So I have read as much as I can understand of the tutorial, and have imported a background into WME for my first scene. I set the scene as the startup scene, and I get the error "variable 'new_actor' is referenced but not defined" what am i doing wrong?
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 191
    • View Profile
Re: "variable 'new_actor' is referenced but not defined"
« Reply #1 on: January 28, 2017, 08:08:28 PM »

You need to show us the contents of scene_init.script to be able to help you.
Logged

futurama140

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: "variable 'new_actor' is referenced but not defined"
« Reply #2 on: January 28, 2017, 09:05:42 PM »

I know I have no clue what i'm doing, but to be honest the documentation doesn't help me for squat, it's really lacking, and there are almost ZERO resources on the internet for WME. The tutorial tells me nothing about stuff I couldn't figure out by tinkering with the engine. Sorry.

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

// here comes the stuff which initializes the scene

new_actor.SkipTo(400, 400);
new_actor.Direction = DI_DOWN;
new_actor.Active = true;


////////////////////////////////////////////////////////////////////////////////
// scene state
global Statestarttest;


// default values
if(Statestarttest==null)
{
  Statestarttest.Visited = false;
  // add scene states here
}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables



////////////////////////////////////////////////////////////////////////////////
if(!Statestarttest.Visited)
{
  Statestarttest.Visited = true;

  // this is our first visit in this scene...
}

Logged

mihaipuiucernea

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 24
  • Currently working on Colors on Canvas
    • View Profile
    • Dev Blog
Re: "variable 'new_actor' is referenced but not defined"
« Reply #3 on: January 29, 2017, 10:09:18 PM »

Make sure this is in your game.script
new_actor = Game.LoadActor("path to your main charcter");
Game.MainObject = new_actor;

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 191
    • View Profile
Re: "variable 'new_actor' is referenced but not defined"
« Reply #4 on: January 30, 2017, 07:16:35 PM »

Make sure that in your base.inc script you have:

Code: WME Script
  1. global new_actor;
  2.  

Also what mihaipuiucernea said needs to be done. Why this you will ask.

Well, the actor variable which already exists is a global variable, meaning that it is maintained regardless in which scene you are and you can use it anywhere. There is a little catch though. To use it in a script you need to have this before using it:

Code: WME Script
  1. global new_actor;
  2. <do stuff with new_actor>
  3.  

You will notice that base.inc is included in all your scripts, be it game.script, in a scene_init.script, in an entity script, anywhere. If you add global new_actor in base.inc, then you can assume that the command runs as soon as base.inc is included, which is always at the beginning of your script. Think of it as code that is always executed.

Don't get carried away though and start adding any global variable you need in base.inc. Add only variables which you will need to use in almost every script. For instance, global Statestarttest; is not a variable you normally need in base.inc, because you most probably will use it only in the scene_init.script and maybe in some of your entities.

There is no shame in being a beginner, we all start somewhere. Bear in mind that the documentation contains everything you will need. What you need now is to become a better programmer and then you will realise that WME is a piece of cake to use. I suggest that you restart the tutorial and do the work that you are instructed to do, instead of just reading it. You will understand many necessary concepts. Your code might initially be a big mess, but you will gradually get better. I suggest that you also read some articles about proper programming style and best practices, they are very useful.
Logged
 

Page created in 0.154 seconds with 17 queries.