Git Product home page Git Product logo

Comments (4)

katawful avatar katawful commented on August 11, 2024

All menu functions (including for MenuQue) support format specifiers. e.g.:

SetMenuFloatValue "some\tile\%g", 1

You can also use them for functions that need a pipe character | but I don't have an example off the top of my head

from xobse.

hartcrompton avatar hartcrompton commented on August 11, 2024

All menu functions (including for MenuQue) support format specifiers. e.g.:

SetMenuFloatValue "some\tile\%g", 1

You can also use them for functions that need a pipe character | but I don't have an example off the top of my head

I have tried: GetTileChildren "%z", TilePath 1011
That just gives me the compile error "Unknown variable FilePath for parameter in."

from xobse.

Forlini91 avatar Forlini91 commented on August 11, 2024

Of all menu commands GetTileChildren and GetTileTraits accept "strings" but not "formatString", which means you can't build the string like that.
When an argument is a "formatString", you can pass extra arguments which will replace the placeholders in the string.
Instead, a "string" argument won't accept extra arguments and you must build the string in some other way.

There are 2 solutions to this problem:

  1. Extract the string from the string_var with the $ operator
string_var TilePath
...
set TilePath to sv_Construct "name1/name2/name3"
GetTileChildren $TilePath 1011
sv_Destruct TilePath
  1. Directly use a quoted string
GetTileChildren "name1/name2/name3" 1011

If you enable the OBSE compiler in that script block (in OBSE Documentation search "Using OBSE expressions in scripts"), you can also build the string in place, example:

string_var middleName
...
let middleName := "name2"
GetTileChildren ("name1/" + $middleName + "/name3") 1011
sv_Destruct middleName

SHORT EXPLANATION:

These commands accept "string" arguments but not "string_var" variables, which means you must "extract" the string from the string_var.
To extract a string from a string_var use the $ operator: it casts ANYTHING to string (extract the string contained in a string_var, convert a number to string, get the "name" of a reference, etc...)

LONG EXPLANATION:

Yes, it's not intuitive. String_var variables are not usable in place of strings (unless you use the $ operator).
String_var and Array_var variables not native in the Oblivion script language. They have been created by the OBSE team and they works similar to a "Ref" type/variable, because they only hold the numeric "reference" or "ID" of the string or the array, not the string/array itself (under the hood, they are actually "numeric" types like the Ref variables).

As a consequence, if you pass a string_var/array_var variable as input to any command means you're passing its numeric ID to the command, which, like in the issue you encountered, means passing a number to a command expecting a pure string. Also, a command argument may either accept a pure string or a string_var, not boths at the same time (so existing Oblivion/OBSE commands can't be "patched" to accept both types).
Luckily, that's not a problem, as arguments accepting a "string" can still be feed a string_var by using the $ operator to extract the contained string, while argument accepting a string_var can be feed a string if you assign that string to a string_var first.

The same problem doesn't happen with arrays, because commands may only accept "references" to array

from xobse.

hartcrompton avatar hartcrompton commented on August 11, 2024

Ah, I knew it missed something. Your explanation also answers a number of (I thought) totally unrelated thoughts I had while looking at the OBSE source.

Wonderful explanation, thank you so much!

from xobse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.