Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Including functions.  (Read 4338 times)

0 Members and 1 Guest are viewing this topic.

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Including functions.
« on: August 20, 2006, 03:25:27 PM »

Hi there. We used during the last two days the "#include "scripts\scriptname.inc" " and it works fine for the purposes we needed it, but then we got a problem. When writing an function in an *.inc it will not work. We could need it really, or a better way to do. The thinking behind this was, to write functions we would need in many scenes, in an separate *.inc script and load it at the position we need via #include "scripts\scriptname.inc"

Thanks for help.

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Including functions.
« Reply #1 on: August 20, 2006, 04:04:02 PM »

although I prefer object approach of thinking, I don't see a reason why this shouldn't work?

I just tried to create a simple inc file with a function

function test()
{
  Game.Msg("Hello World");
}

and in the scene_init.script I've added
#include "scripts/test.inc"
just below the first include

Then I tried

test();

and it worked. So where exactly is your problem.

And please be more specific of what doesn't work. It would be faster to help you. You can always post debug logs to show us where are you stuck. Also you can read great article about bug reporting clicking on the link in Mnemonic's signature. ;)

let me know what's the actual problem.

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: Including functions.
« Reply #2 on: August 20, 2006, 04:18:33 PM »

Ok, thank you, I do not know why, but WME jumped over the jordan. We try again, maybe there is a little error, we've missed.

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Including functions.
« Reply #3 on: August 20, 2006, 04:32:51 PM »

btw. the log file is situated in the root directory of your project and it's called wme.log so that's the file you will need to examine for future references. (sorry if you know this already)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: Including functions.
« Reply #4 on: August 20, 2006, 04:36:48 PM »

Yes I already know, unfortunately, I am only a modeller and the translator from german to english.
Wait a minute, we are on it.

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: Including functions.
« Reply #5 on: August 20, 2006, 05:00:13 PM »

Ok the problem is the following. We have:

if(condition) #include "scripts/test.inc"

This works fine, when no function is in test.inc. But if there is one, we got a syntax error in the script where the function gets started via include. Is the include command without an condition at the beginning of the script, it works. But we need it at a later part of the script.

Hope I wrote it clear enough

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: Including functions.
« Reply #6 on: August 20, 2006, 06:11:12 PM »

Another question about include.
How does it really works? Is it some kind of a link or does it really include the whole script. I ask because of the memory usage. I think it would make a big difference, am I right?

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Including functions.
« Reply #7 on: August 20, 2006, 06:34:09 PM »

Imagine the #include directive as copying the contents of the entire include file replacing the #include line. That's exactly how it works. That also explains why that condition you wrote above can never work.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Including functions.
« Reply #8 on: August 20, 2006, 06:35:54 PM »

include really include the whole file. conditional includes as you show them couldn't work (in any to me known languages) and
have no real sense. In C++ you have conditional includes for preprocessor and their meaning is usually architecture customizing.

In the WME case there's no real purpose why doing that. Also memory usage is not an issue at all, since graphics and audio takes
thousand times more memory than your scripts.

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Amo

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 206
    • View Profile
    • Sunrise The Game
Re: Including functions.
« Reply #9 on: August 20, 2006, 07:48:49 PM »

Imagine the #include directive as copying the contents of the entire include file replacing the #include line. That's exactly how it works. That also explains why that condition you wrote above can never work.

Ok, we compared the WME script language with that from Flash. In Flash and in Toolbook since Version 4.1 or 2 would it work. But that doesn't matter, we will do it on another way.
 

Page created in 0.029 seconds with 18 queries.