Jump to content
  • 0
AleksB

Scripting error

Question

Hey all!

 

SO im trying to set an action where you pick up a soulsphere and once its picked up, a bunch of hell knights spawn in.  I wrote the script, but its saying I have an error and I cant figure out why.

 

1 #include "zcommon.acs"

2

3 script 1 (void)

4

5 Thing_SpawnFacing(30, 113, 0, 999);

6

7 Delay(50)  (this one is the error)

8

9 thing_spawnfacing(31, 113, 0, 999);

10

11 delay(50)

12

13 thing_spawnfacing(32, 113, 0, 999);

14

15 delay(50)

16

17 thing_spawnfacing(33, 113, 0, 999);

 

ANy help is appreciated.  Thanks!  This is in gzdoombuilder btw

Share this post


Link to post

36 answers to this question

Recommended Posts

  • 0

You are missing a lot of formatting it seems:

#include "zcommon.acs"
script 1 (void)
{
    Thing_SpawnFacing(30, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(31, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(32, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(33, 113, 0, 999);
}

However, if you want be be advanced:

#include "zcommon.acs"
script 1 (void)
{
    for(int i = 30; i <= 33; i++)
    {
        // T_HELLKNIGHT is thing type 113
        Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999);
        delay(50);
    }
}

Or if you want to be really advanced & safe:

#include "zcommon.acs"
script 1 (void)
{
    int i = 30;
    while(i <= 33)
    {
        // T_HELLKNIGHT is thing type 113
        if(Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999) > 0)
        {
            // Confirm the object spawned
            i++;
        }
        delay(50);
    }
}

 

Share this post


Link to post
  • 0
17 minutes ago, Edward850 said:

You are missing a lot of formatting it seems:


#include "zcommon.acs"
script 1 (void)
{
    Thing_SpawnFacing(30, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(31, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(32, 113, 0, 999);
    delay(50);
    Thing_SpawnFacing(33, 113, 0, 999);
}

However, if you want be be advanced:


#include "zcommon.acs"
script 1 (void)
{
    for(int i = 30; i <= 33; i++)
    {
        // T_HELLKNIGHT is thing type 113
        Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999);
        delay(50);
    }
}

Or if you want to be really advanced & safe:


#include "zcommon.acs"
script 1 (void)
{
    int i = 30;
    while(i <= 33)
    {
        // T_HELLKNIGHT is thing type 113
        if(Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999) > 0)
        {
            // Confirm the object spawned
            i++;
        }
        delay(50);
    }
}

 

Thats strange, because, I saw chubsdoomer do it and I basically copied it from him.  And also that only line 7 (delay 50) was only affected.  So can I copy one of these and put it in the script, then it should work?  What formatting am I missing?

Share this post


Link to post
  • 0

Well maybe he sucks at ACS because you should never write repeating code like that in any programming language really...

 

Oh and yes, the version @Edward850 wrote should work assuming the place you have the hell knight set to spawn at is valid, iirc it needs to be a MapSpot to work, I tried spawning an enemy on an object that wasn't a Mapspot one time when i very first started mapping a couple of months ago and it didn't work...

Edited by therektafire

Share this post


Link to post
  • 0
Just now, therektafire said:

Well maybe he sucks at ACS because you should never write repeating code like that in any programming language really...

Thanks for the comment.  Really wasnt needed. This is my first crack at it.

Dude27th likes this

Share this post


Link to post
  • 0
5 minutes ago, AleksB said:

Thanks for the comment.  Really wasnt needed. This is my first crack at it.

Edited the comment with somewhat more helpful things

 

Also I wasn't trying to be mean towards you or anything, I'm just saying that you probably shouldnt be watching coding tutorials from someone who writes code like that... I watched chubz's mapping tutorials and they are pretty good though

AleksB likes this

Share this post


Link to post
  • 0
15 minutes ago, AleksB said:

So can I copy one of these and put it in the script, then it should work?  What formatting am I missing?

Yes, any of those 3 examples will work, with the last one ensuring that all Hell-Knights will always be spawned. Assuming the line numbers weren't supposed to be there, you were missing curly braces ('{' and '}', denoting the start and end of the code block) and the semi-colon (';') at the end of the delay functions, which indicates the end-of-line for functions.

AleksB likes this

Share this post


Link to post
  • 0
10 minutes ago, therektafire said:

Edited the comment with somewhat more helpful things

 

Also I wasn't trying to be mean towards you or anything, I'm just saying that you probably shouldnt be watching coding tutorials from someone who writes code like that... I watched chubz's mapping tutorials and they are pretty good though

Oh okay my bad man, I thought that was towards me.  Im sorry :)  If your curious, this is the video.  Skip halfway and youll see what I mean

 

 

 

Share this post


Link to post
  • 0
2 minutes ago, Edward850 said:

Yes, any of those 3 examples will work, with the last one ensuring that all Hell-Knights will always be spawned. Assuming the line numbers weren't supposed to be there, you were missing curly braces ('{' and '}', denoting the start and end of the code block) and the semi-colon (';') at the end of the delay functions, which indicates the end-of-line for functions.

Thanks man, I used the first one and it worked.  I appreciate it.  made many maps before, but never tried scripting, so Figured Id give it a shot

Share this post


Link to post
  • 0
1 hour ago, therektafire said:

Well maybe he sucks at ACS because you should never write repeating code like that in any programming language really...

Chubz was fine, AleksB just copied it wrong. Although I don't understand what's wrong with repeating code in this case, or in the case of the example Chubz used. I mean sure you could use a loop but why do a loop for something so simple and short. I've written many scripts like this without ever having problems or noticing any kind of slowdown or bad effect. From what I can tell stuff like this is always subjective opinion, and I don't really like it when others say you SHOULD do something a certain way unless it IS bad practice. If there is something actually wrong about that approach, please say it.

 

 

2 hours ago, Edward850 said:

Or if you want to be really advanced & safe:


#include "zcommon.acs"
script 1 (void)
{
    int i = 30;
    while(i <= 33)
    {
        // T_HELLKNIGHT is thing type 113
        if(Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999) > 0)
        {
            // Confirm the object spawned
            i++;
        }
        delay(50);
    }
}

 

How does this one work? I didn't know you could use Thing_SpawnFacing in an if block to determine an action. Although I don't think this will work for my purposes as I spawn using a custom function.

Share this post


Link to post
  • 0
3 minutes ago, Nevander said:

How does this one work? I didn't know you could use Thing_SpawnFacing in an if block to determine an action. Although I don't think this will work for my purposes as I spawn using a custom function.

Thing_SpawnFacing is a line action which returns success, to which I assume in ZDoom line actions can be checked for success in ACS. But even if they can't, the generic Spawn functions absolutely do return the number of actors successfully spawned and thus can be subject to checks.

Share this post


Link to post
  • 0
10 hours ago, Nevander said:

How does this one work? I didn't know you could use Thing_SpawnFacing in an if block to determine an action. Although I don't think this will work for my purposes as I spawn using a custom function.

You can make your custom function return a value.

Share this post


Link to post
  • 0
16 hours ago, Nevander said:

Chubz was fine, AleksB just copied it wrong. Although I don't understand what's wrong with repeating code in this case, or in the case of the example Chubz used. I mean sure you could use a loop but why do a loop for something so simple and short. I've written many scripts like this without ever having problems or noticing any kind of slowdown or bad effect. From what I can tell stuff like this is always subjective opinion, and I don't really like it when others say you SHOULD do something a certain way unless it IS bad practice. If there is something actually wrong about that approach, please say it.

 

 

How does this one work? I didn't know you could use Thing_SpawnFacing in an if block to determine an action. Although I don't think this will work for my purposes as I spawn using a custom function.

Thats the thing, only line 7 in the script was the error.  It was the same as the other lines in the script.  Why would the other delay commands be fine, but only line 7 the error?

Share this post


Link to post
  • 0
7 minutes ago, AleksB said:

Thats the thing, only line 7 in the script was the error.  It was the same as the other lines in the script.  Why would the other delay commands be fine, but only line 7 the error?

Because based on the code in the OP you are missing a lot of formatting like brackets and semicolons. In that video, Chubz has the formatting. So somewhere that formatting got lost in translation. I don't know why it went to line 7 for the error, it should have gone to line 3 or 4 first. I'd imagine it would have detected no body for the script and threw that first, but sometimes errors are just wrong.

AleksB and therektafire like this

Share this post


Link to post
  • 0
2 minutes ago, Nevander said:

Because based on the code in the OP you are missing a lot of formatting like brackets and semicolons. In that video, Chubz has the formatting. So somewhere that formatting got lost in translation. I don't know why it went to line 7 for the error, it should have gone to line 3 or 4 first. I'd imagine it would have detected no body for the script and threw that first, but sometimes errors are just wrong.

Oh I was using () instead of the brackets.  That makes sense.  Yea this is my first crack at scripting, so idk whats the right and wrong ways you know?  Ive made many maps, but never bothered with scripts.  Makes me feel like a noob all over again lol

Share this post


Link to post
  • 0

It's ok, it gets easier. I never though I could use ACS and UDMF and now I'm writing all kinds of crazy shit and coding my own puzzles entirely with ACS. Stick at it, you'll get the hang of it in no time.

AleksB and therektafire like this

Share this post


Link to post
  • 0
4 minutes ago, Nevander said:

It's ok, it gets easier. I never though I could use ACS and UDMF and now I'm writing all kinds of crazy shit and coding my own puzzles entirely with ACS. Stick at it, you'll get the hang of it in no time.

Got anything I can check out?  Im curious to see what youve came up with

therektafire likes this

Share this post


Link to post
  • 0
2 minutes ago, AleksB said:

Got anything I can check out?  Im curious to see what youve came up with

You could download Doom 64 Retribution and then open it in SLADE and go through all the SCRIPTS lumps for the maps.

therektafire and AleksB like this

Share this post


Link to post
  • 0
2 minutes ago, Nevander said:

You could download Doom 64 Retribution and then open it in SLADE and go through all the SCRIPTS lumps for the maps.

Ill check it out.  What about wads?

Share this post


Link to post
  • 0
14 minutes ago, Nevander said:

It is a WAD file. It basically replaces all of Doom 2 with Doom 64.

I like the arena level that was fun!  How long did that take you to make?  The whole wad I mean

Share this post


Link to post
  • 0
8 hours ago, AleksB said:

How long did that take you to make?  The whole wad I mean

Like... maybe half a year and I'm still working on it, trying to bring over more levels that were made for an older TC called Doom 64 Absolution TC. It's been over a year since I started work on it. Damn where'd the time go.

AleksB and therektafire like this

Share this post


Link to post
  • 0
16 minutes ago, Nevander said:

Like... maybe half a year and I'm still working on it, trying to bring over more levels that were made for an older TC called Doom 64 Absolution TC. It's been over a year since I started work on it. Damn where'd the time go.

I hear ya on that one haha.  Well I can see the kinda work you put into it thus far, and i can tell it paid off so far.  Im currently working on one of my wads, probably have about 50 hours, not including the 9 and a half hours that i put into it today lol.  Still working on it as we speak lol.  Cant believe how late it is already

therektafire and Nevander like this

Share this post


Link to post
  • 0

Okay guys, Another question.  So Im so close to finishing my map.  I went to test it, and the first script I used worked, then I just tried to test it, and now it says the script is unknown.  Idk what happened, I didnt change anything.  I made another script for a different part of the map also.  Could that affect it?  Here is the script that has an error.

 

#include "zcommon.acs"  (now this one is the error)
 script 1 (void)
{
    for(int i = 30; i <= 33; i++)
    {
        // T_HELLKNIGHT is thing type 113
        Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999);
        delay(50);
    }
}

 

 

Like I said, idk what happened, it worked then all of a sudden it stopped.  Any suggestions?

 

Here is the second script just incase

 

#include "zcommon.acs"
script 2 (void)
{
    for(int i = 80; i <= 80; i++)
    {
        // T_CHAINGUY is thing type 2
        Thing_SpawnFacing(i, T_CHAINGUY, FALSE, 999);
        
    }
}

Share this post


Link to post
  • 0
3 minutes ago, Edward850 said:

You only need to include zcommon once.

For multiple scripts?  I wrote two seperate scripts.

Share this post


Link to post
  • 0

Yes, even with multiple scripts, as it is actually unrelated to scripts. #include is a compile time directive which makes it include that file, which has all the definitions... uh... defined. Including it twice would mean forcing the compiler to define all of it twice, which is usually bad.

Edited by Edward850
AleksB and therektafire like this

Share this post


Link to post
  • 0
1 minute ago, Edward850 said:

Yes, even with multiple scripts, as it is actually unrelated to scripts. #include is a compile time directive which makes int include that file, which has all the definitions... uh... defined. Including it twice would mean forcing the compiler to include it twice, which is usually bad.

Well for script two, I just deleted the the #include zcommon.acs, so I guess i will try to compile em and see what happens

Share this post


Link to post
  • 0

That didnt work.  I keep playing with it and im still getting the error.  What else can I try?

 

 

#include "zcommon.acs"
script 1 (void)
{
    for(int i = 30; i <= 33; i++)
    {
        // T_HELLKNIGHT is thing type 113
        Thing_SpawnFacing(i, T_HELLKNIGHT, FALSE, 999);
        delay(50);
    }
}

script 2 (void)
{
    for(int i = 80; i <= 80; i++)
    {
        // T_CHAINGUY is thing type 2
        Thing_SpawnFacing(i, T_CHAINGUY, FALSE, 999);
        
    }
}

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×