Jump to content

setting script variables in dialog


Ruadhan2300

Recommended Posts

Bit of a conundrum here, I've got a unique protectron character who acts a bit like a follower, you get two dialog options with him, Follow and Wait.

they control behaviour packages in the NPC.

its the bit in between which is the problem, the script to change a variable which is detected by conditions in the packages.

or is there a better way to do this?

 

Conversation -> little scripts to set variables in...-> Script in the character -> Packages reference the variables from that script.

 

suffice to say it doesn't work. the little scripts in the conversation won't compile (Set Scriptname.Mode to 1)

where Scriptname is the name of the script held inside the NPC. and Mode is the only variable in it.

 

also for some reason the getScriptVariable function won't detect Mode. this may be related....am I doing something really stupid?

Link to comment
Share on other sites

You don't reference script names in scripts. You reference the, er, reference or quest the script is attached to.

Also, you should check out GECK power up, it will bring back your GECK errors so you'll know (more) what the problem is when trying to compile your scripts.

Link to comment
Share on other sites

What most people do is define a variable in a quest or object script (where the object has a persistent reference). Then in the dialog script, set the variable. In the package, use the variable as a condition. Then, pray it works. For example, suppose you have a quest named foo, and its associated quest script is named bar, and your variable inside "scn bar" is named gribbix.

 

(Edited next line to correct it, as pointed by Quetzl below)

 

Then in the dialog script box, "set foo.gribbix to 1". In your package, use a condition "getquestvariable" "foo" "gribbix" "==" "1".

 

Many people find that packages work erratically, and it is necessary to try several styles before finding one that works, and the style that works for one task will not work for what seems to be a very similar task. If there is any expert who can explain exactly what works, they haven't posted here yet.

Edited by davidlallen
Link to comment
Share on other sites

If the quest is named "foo", then your syntax would read:

 

set foo.gribbix to 1

 

and

 

getquestvariable foo gribbix == 1

 

You don't use the script names anywhere in any script, other than declaring the name (scn bar).

Edited by Quetzlsacatanango
Link to comment
Share on other sites

hm, so the quest "bar" would be attached directly to the quest? or to the NPC? or to a placeholder entity?

this is one of the functional problems I've been having..

 

 

Edit:

 

my current layout is that I have a Quest called 00V105FatsoController. three topics in it, a greeting, and two command topics for Follow and Wait. also attached to that quest is a quest-script called 00FatsoScript

which contains the following code:

 

scn 00FatsoScript

Short Mode

Begin GameMode

End

 

my topics are designed to set the variable in the script (Mode) to 1 or 2 depending on which package I want.

the command for Follow is:

 

Set 00V105FatsoController.Mode to 1

 

but for some reason won't compile.

 

 

in the NPC itself, there are two AI packages, one for follow, one for wait. I know those work fine because I tested them with an alternative system earlier. their conditions use GetScriptVariable functions to work out which package to use at any one time.

 

simple enough in concept, but for some reason it won't work.

 

All the above codes and scripts are direct Copypasta's from the program, so any mistakes in them are mistakes in my code that are probably responsible for the trouble :P

 

 

DoubleEdit:

looks like the GetScriptVariable function is looking for an entity, clearly the NPC itself isn't what its looking for because the script isn't attached to that...so...bit unsure what to do.

Edited by Ruadhan2300
Link to comment
Share on other sites

The script "bar" would be attached directly to the quest, or NPC. It can be either one. If you attach to the NPC, it has to have a persistent reference. Refs use getscriptvariable, quests use getquestvariable.

So if you put it on your NPC, you would use:

 

mynpcref.getscriptvariable gribbix == 1

 

Replace mynpcref with the refID of your NPC.

Edited by Quetzlsacatanango
Link to comment
Share on other sites

Never, never use script or variable names that start with numbers. If you saw this in an example somewhere, please let us know where. Many first time modders do this and then get unexpected syntax errors. This behavior must be learned from somewhere. I would like to let them know they are leading people astray.
Link to comment
Share on other sites

Ah! David, that's gotta be the problem I've been having right there, and no, its not a bad habit I've learnt from any example, its just a holdover from the good habit from all the rest of my modding..

 

thanks guys for the excellent advice and assistance.

 

Edit:

 

Okay, continuing with the same problem as before :P

Set 00V105FatsoController.Mode to 1

won't compile.

that being the bit in the topic which sets the "gribbix" variable.

I've now set it up so that the script "bar" is attached to the quest (same quest as its being called from.)

also changed the Scriptname so that it no longer starts with 00. is it a problem if the questname being referenced also starts 00?

 

Here's a pic.

http://newvegasnexus.com/imageshare/images/1454396-1301131420.jpg

 

Any suggestions? or am I totally misunderstanding the system :P

 

 

Edit2: Holy crap...I feel stupid now. yes, evidently starting anything with 00 at the start in a script fuxes it up. no wonder I'd been having problems. I removed the 00 on the start of the control quest and made relevant changes in the scripts and it hasn't errored at me....

Edited by Ruadhan2300
Link to comment
Share on other sites

ok, seems to be working as intended now...

new and fun problems to deal with though.

first and foremost, the faction. this is a modified protectron initially belonging to the vault it's found in. the idea is that you can acquire it as a companion of sorts (it follows basic instructions to follow and wait, and I'll add an inventory that can be accessed later)

right now it attacks -anything- not belonging to the vault faction, or specifically noted as allied/friendly to that faction. this includes Raiders, Malcom Holmes, Radscorpions and ravens...is there a general Companion faction I can add it to that will make it attack only things that are specifically hostile to my player-character?

 

Edit, fixed that problem, now I'm trying to make an accessible inventory for Fatso. using a container linked to his merchant container options, I can trade with him, but whenever anything is added to his inventory it gets deleted from it...or something. its like he can put things into the box but can't take them out again.

Edited by Ruadhan2300
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...