Scripting Q

   3110   3   0
User Avatar
Member
132 posts
Joined: July 2005
Offline
I have a file a friend sent me to debug. The first thing I noticed is he has about 50 pop networks and each of them has an incorrect reference in the source pop /impulserate parameter.

Since his popnet1 needs to reference an object called…/sort1, I figured I should write a little script to go in there and fix the bad paths for him.

So far I have this:

for i = 1 to 21

chrmkey -t 0 /obj/geo1/break_shit/popnet${i}/source${i}/impulserate

chkey -t 0 -v 0 -m 0 -A 0 -F ‘nprims(“/obj/geo1/break_shit/sort${i}”)/1’ /obj/geo1/break_shit/popnet${i}/source1/impulserate

end

================

This works great except for one thing… it puts this into the parameter:

nprims(“/obj/geo1/break_shit/sort${i}”)/1

================

What I want it to do, is for each {i} put the value in its place like so:

nprims(“/obj/geo1/break_shit/sort1”)/1 (where the 1 in sort1 is sort${i} evaluating for the first time.

================

Obviously it's the chkey command followed by the string designated by the ticks `` that's throwing this off. But how do I get around this?
User Avatar
Member
7754 posts
Joined: July 2005
Offline
You can just break up the expression so that the ${i} is outside of the single quotes that is preventing the expansion. ie. enclose ${i} in its own set of single quotes.

chkey -t 0 -v 0 -m 0 -A 0 -F ‘nprims(“/obj/geo1/break_shit/sort’${i}'”)/1' …
User Avatar
Member
132 posts
Joined: July 2005
Offline
Here's what it puts into my Impulse Birth Rate when I do what's been recommended:

nprims(“/obj/geo1/break_shit/sort`${i}`”)/1

Notice the ticks remain intact – not exactly what we wanted :wink:

The problem is I'm entering a string into a parameter using the chkey command. chkey allows you to set a key, set the frame for the key, and set the value for the key. In this case I'm setting a string instead of a value, so I have to indicate that it's a string by using the ``

Once I do that, it's no longer evaluating the section within the ``'s as part of my “for each” loop.
User Avatar
Member
132 posts
Joined: July 2005
Offline
SOLUTION FOUND!



for i = 1 to 21

chrmkey -t 0 /obj/geo1/break_shit/popnet${i}/source${i}/impulserate

chkey -t 0 -v 0 -m 0 -A 0 -F ‘nprims(“/obj/geo1/break_shit/sort’${i}'”)/1' /obj/geo1/break_shit/popnet${i}/source1/impulserate

…So something I did during my last post mustve been wrong… and Edward gets kudos for having the solution all along
  • Quick Links