Jump to content

Set global variable (265)


Thimblerig

Recommended Posts

Picking around in NearInfinity, you can see among the effects that you can grant an item, "Set global variable (265)".

 

I'm curious - has anybody actually used that effect? (Or its siblings "Set local variable (187) and (309)"?

 

If so, how did it work out for you? And however did you specify which global because I can't for the life of me work out how...

 

**

 

Oh, wait - just found the field "String". That looks very promising: off to have a play.

Link to comment

I'm using opcode 265 in one of my mods (via EFF files) and it works flawlessly. It basically works the same as the script action SetGlobal() using the "GLOBAL" scope. You'll have to spread your variable name over the fields 'String', 'Resource 2' and 'Resource 3' since each field is limited to 8 characters.

Link to comment

You set the variable string in the tp2 by:

 

COPY ~c#greythedog/items/C#GrWhis.ITM~ ~override/C#GrWhis.ITM~
WRITE_ASCII 0xee ~C#GrCall~ #8

 

I use it for a whistle that calls the dog if he is away. Works like a charm.

Link to comment

You set the variable string in the tp2 by:

 

COPY ~c#greythedog/items/C#GrWhis.ITM~ ~override/C#GrWhis.ITM~

WRITE_ASCII 0xee ~C#GrCall~ #8

That's all nice and dude, but the index (0xee) is a little out of the initial index range, so do you have applicable theory on how to calculate the index ? Or editor that shows the byte number ?

Like say you actually patch the item with the opcode and then the global name etc. with for example the ADD_ITEM_EFFECT or some other function.

Link to comment

 

 

Jarno is right, you have to look up the offest of the String for your item with NI, the number above is for my specific case, but in principle the code is correct.

 

I used Argent77's version - filling in the string field in the item stub in NI. It worked okay. (And I wanted to adapt a potion that already did something else, so that seemed a bit easier.)

 

So... if I wanted to patch that in the tp2, I'd look up the String field? NI says that the offset is "be h" - so the line would turn into:

 

 

 

WRITE_ASCII 0xbe h ~T1CowMoo~ #8

 

Is that right? How does one determine the value of the variable?

Link to comment

So... if I wanted to patch that in the tp2, I'd look up the String field? NI says that the offset is "be h" - so the line would turn into:

WRITE_ASCII 0xbe h ~T1CowMoo~ #8

 

The " h" likely to be a sign that the number is in hex based, so you just put this:

WRITE_ASCII 0xbe ~T1CowMoo~ #8

As the "0x" is the representation for the hex in .tp2...

 

Ahh, the NI has the option to show the hex offsets, but it's turned off by default... which is why I asked originally, cause I didn't know, thanks jastey.

 

 

 

Is that right? How does one determine the value of the variable?

Well, with this:

#265 (0x265) Script: Modify Global Variable [265]

Parameter #1: Value

Parameter #2: Type

Description:

Alters the global variable specified by the resource key, in the style specified by the 'Type' field, by the value specified by the 'Value' field.

Known values for 'Type' are:

0 Set Global (to 'Value')

1 Increment Global (by 'Value')

NB. Since the Resource Key can only be 8 characters long maximum, you can not set a Local Variable with this effect this has a name longer than this amount.

AKA, the parameters #1 and #2, while the WRITE_ASCII is the "Resource Key". And those come from the .itm structure, so if the resource is "0xbe", then the parameter 1 is "0xb4" and parameter 2 is "0xb8". At least hopefully.

 

I would of course do this with the ADD_ITEM_EFFECT which saves us from counting the bytes. To an item that doesn't have the effect in the first place...

Say like you want to for whatever reason:

COPY ~Impsfart/impsfart.ITM~ ~override/IJ#fart.itm~
LPF ~ADD_ITEM_EFFECT~ INT_VAR opcode=265 timing=0 parameter1=1 parameter2=0 STR_VAR resource=IJ#fart END
BUT_ONLY

Yyh, you just opened my fart bag, it smells really foul even up to here. :p

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...