Author Topic: Another Material Question  (Read 465 times)

0 Members and 1 Guest are viewing this topic.

argoon

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +21/-81
  • Doom Newbie
    • View Profile
Re: Another Material Question
« Reply #15 on: August 31, 2017, 09:27:19 PM »
argoon thanks for your posts.

Сan I ask a few questions about example above?

1. What is the expression '#ifndef' (it's not about general purpose, it's about D3 scripting)?

2. If entity on the map have a scriptobject and init() as described above then it (init) will be start at start of level? IMO this is not typical behavior for level script wich must be placed in /maps, not in /script.

Those are called pre-processor keywords on c and c++, they are special keywords that are run before the script compiler, they are used by script engine to create macros and Global variables, etc. In this case i'm defining _LOOK_AT_  before compilation so any variable i put inside this script doesn't conflits with variables with the same name on other script files.  Is akin to using the:  "using namespace mapname" keyword for map scripts.

About the second question, this is not a map script, this is a object script and those go on the script folder, init() in a object script is just like constructors in c++, so any function inside init() will run at the exact moment the entity (object) spawns in the game, it can be at level start or not.

Quote
You mention the entity and the map, but it's not a single entity but rather all instances of a material I need it to work on, and that's on any map.

object scripts run on any map the object exists, because they are called by the entities them self's at spawn time.

To know more about this i recommend that you guys read about OOP programming (Object Oriented Programming).   
« Last Edit: August 31, 2017, 09:29:33 PM by argoon »

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #16 on: August 31, 2017, 09:46:15 PM »
Would love to learn more, but I'm already busy now studying something else. :|

I'm wondering what I should put in for "$entityName". I'm working with models/mapobjects/tablecart1ball, so would tablecart1ball be the entity name?

bitterman

  • Sr. Member
  • ****
  • Posts: 262
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Another Material Question
« Reply #17 on: September 01, 2017, 11:44:28 PM »
Btw when I try to replace 'while(1)' to 'eachFrame' (for level script) I get an error "Built-in function can't be used without an object".

« Last Edit: September 01, 2017, 11:46:17 PM by bitterman »

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Another Material Question
« Reply #18 on: September 02, 2017, 09:13:35 AM »
Try sys.eachFrame

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Another Material Question
« Reply #19 on: September 02, 2017, 09:35:16 AM »
models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

argoon

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +21/-81
  • Doom Newbie
    • View Profile
Re: Another Material Question
« Reply #20 on: September 02, 2017, 09:44:19 AM »
Btw when I try to replace 'while(1)' to 'eachFrame' (for level script) I get an error "Built-in function can't be used without an object".

Hum I didn't knew that was locked to objects only, need to study why, I'm working on engine c++ so have not scripted any level for a while now.
I'm not near my computer tho so will see later, for now continue using while loop for level scripting as always, sorry.

Try sys.eachFrame

sys is indeed a object but eachframe that I recommend is not a c++ function, callable by sys, is just a script macro made using #define, it is written at the bottom of the doom_defs.script if I'm recalling correctly.


models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

Exactly my script needs to be assigned to a entity in the editor or on a def file, it has no knowledge of materials it will only change the yaw (rotation) of a object no matter the materials on its surface.



bitterman add a thought, I assume you're calling your map script from within the map folder, using the script with the map name next to the map file,  perhaps that is why it doesn't work, if you open the script folder you see Id software put map scripts there as well, and call them from the doom_main.script just like with objects. The difference with this method is that you need to enclose your script code inside a "use namespace mapname" or all function/variables names will conflict with each other.
« Last Edit: September 02, 2017, 10:26:10 AM by argoon »

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #21 on: September 03, 2017, 03:55:00 AM »
models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

So much for that...

argoon

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +21/-81
  • Doom Newbie
    • View Profile
Re: Another Material Question
« Reply #22 on: September 03, 2017, 10:44:33 AM »
models/mapobjects/tablecart1ball

This is the object that I want it to apply to. When you say player script, you mean doom_main.script? There's no player.script. Is this all 1 set of instructions or 2 ways of doing it?

That isn't a object, its a material. That script won't help you without one.

So much for that...

Materials are attached to objects, deform sprite also rotates the object not the material itself plus deform sprite requires models made of a single flat face (a plane), wheres my script works with any object.
You need to find, using the editor, all the objects using that material, Dark Radiant (from the DarkMod) has a option where it will select all objects using the same material, with all selected you can assign the key value, i suggested, to all of them at the same time.

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #23 on: September 04, 2017, 02:26:25 AM »
There are table carts throughout the game though.

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Another Material Question
« Reply #24 on: September 04, 2017, 03:48:50 AM »
Try finding the entity def of these table carts you are talking about.

If I recall r_showSurfaceInfo set to 1 should show the entity def of what you are looking at. If not try grabbing the table cart with editAFs. If not that, type editDecls in console and search for 'models/mapobjects/tablecart1ball'. Check under entityDefs for any possible hits.
« Last Edit: September 04, 2017, 03:54:52 AM by Phrozo »

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #25 on: September 04, 2017, 04:17:21 AM »
r_showsurfaceinfo comes back with models/mapobjects/tablecart2 and the files for them are in models/mapobjects/lab/tablecart1 and tablecart2
« Last Edit: September 04, 2017, 04:20:58 AM by spamclark15 »

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Another Material Question
« Reply #26 on: September 04, 2017, 04:19:55 AM »
That's a material...

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #27 on: September 04, 2017, 04:31:35 AM »
moveable_compcart, moveable_tablecart1, moveable_tablecart2

These are the entity defs. These 3 all use that wheel material.
« Last Edit: September 04, 2017, 04:42:27 AM by spamclark15 »

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: Another Material Question
« Reply #28 on: September 04, 2017, 10:43:28 AM »
Now you can try scripting for these table carts. Make a new script file if you haven't already.


If you are not sure which one to edit just edit all of them and add the key "scriptobject" with the name of the script object you made in quotes. Then when they spawn, each table cart will run that script.

spamclark15

  • id Enthusiast
  • Jr. Member
  • **
  • Posts: 97
  • Karma: +10/-3
  • A missile-launching skyscraper with goat legs.
    • View Profile
Re: Another Material Question
« Reply #29 on: September 04, 2017, 12:12:48 PM »
Alright, created lookat.script, containing:

Code: [Select]
#ifndef _LOOK_AT_
#define _LOOK_AT_

object lookAT {


vector plAngles;

entity player;


void init();
void lookAtPlayer();
};

void lookAT::init()
{
player = $player1;

        thread lookAtPlayer();
}


void lookAT::lookAtPlayer()
{
      eachFrame
      {
           plAngles = player.getViewAngles();

   plAngles_x = 0;
   plAngles_y = plAngles_y + 90;
   plAngles_z = 0;
   self.setAngles(plAngles);
      }
}
#endif

Changed doom_main.script to contain:

Code: [Select]
#include "script/ai_base.script"
#include "script/lookat.script"

The 3 carts are found within moveable.def. Other than map files, this is the only file that makes reference to those entity defs. I'm not clear on what to do next. I'm adding "lookat" to another script file?