Cerez Posted August 16, 2015 Posted August 16, 2015 I have a (sort of) noobie scripting/coding question for the O'wiser ones: If I want to get and set CVARs as variables from within an ICARUS script, how would I go about that? I'm familiar with how to set variables, but I can't find any reference in the documentation to reading or affecting CVARs using ICARUS. Can I pass a variable value from an ICARUS script to then process it using the command line (through CFG)?
Cerez Posted August 16, 2015 Author Posted August 16, 2015 @@mrwonko, so in other words, I'd have to code this feature into the game (a.k.a. ICARUS interpreter rewrite)? What about querying the active player settings? Is there any way to do that through ICARUS scripting currently?
mrwonko Posted August 16, 2015 Posted August 16, 2015 @@mrwonko, so in other words, I'd have to code this feature into the game (a.k.a. ICARUS interpreter rewrite)?Yes. Though cvars are presumably just a means to an end here, you may want to just add whatever you're trying to achieve using cvars to ICARUS. What about querying the active player settings? Is there any way to do that through ICARUS scripting currently?What exactly do you mean by active player settings? You can query the difficulty level, for example, is that a player setting? Are we talking MP or SP? But I suspect the answer to your question is no. Cerez likes this
Cerez Posted August 16, 2015 Author Posted August 16, 2015 What exactly do you mean by active player settings? You can query the difficulty level, for example, is that a player setting? Are we talking MP or SP? But I suspect the answer to your question is no. Thanks. I meant it for SP, and yes, the difficulty level, or player's gender, etc. Game settings that the player accumulates during the run of the game.
eezstreet Posted August 16, 2015 Posted August 16, 2015 You can get both the difficulty and sex via a GET command. Cerez likes this
Cerez Posted August 16, 2015 Author Posted August 16, 2015 Thanks Eez. I'll have a look into this. What about the current player model or skin(s)? Maybe ICARUS has a different means of accessing these settings than directly through the CVARs. This is crucial if I want to do any more advanced, interactive SP scripting for the game. Edit: But I take it it still can't set any of these values to be used by the game outside of the script, right?
eezstreet Posted August 16, 2015 Posted August 16, 2015 Yes. Also you can enter a cvar into a GET on OpenJK. Cerez likes this
Cerez Posted August 16, 2015 Author Posted August 16, 2015 So I could get(STRING, "mapname") in OpenJK? Or is it: get(CVAR, "mapname")
Cerez Posted August 16, 2015 Author Posted August 16, 2015 But I can't do set("mapname", "yavin1b") right? I take it for game security reasons?
redsaurus Posted August 16, 2015 Posted August 16, 2015 you actually have to do get(STRING, "cvar_mapname") or set("cvar_whatever", "whatever") this is only for SP. Cerez, therfiles and eezstreet like this
eezstreet Posted August 16, 2015 Posted August 16, 2015 you actually have to do get(STRING, "cvar_mapname")or set("cvar_whatever", "whatever")this is only for SP.ty, I forgot how I set this up.
Cerez Posted August 16, 2015 Author Posted August 16, 2015 Thanks @@redsaurus. Is this a recent implementation into OpenJK? How long have we had this working? The reason I'm asking is because while I can set a CVAR from ICARUS, I can't seem to be able to retrieve one. My game crashes when trying to get a value from a CVAR. I've created this simple script to test it, but yeah... I'm getting this quite curious behaviour -- unless I'm doing something wrong and I'm not aware of it: declare( STRING, "playergen" ); if ( get(STRING, "cvar_sex") = "m" ) { set( "cvar_sex", get(STRING, "playergen") ); free( "playergen" ); } else { set( "playergen", get(STRING, "cvar_sex") ); set( "cvar_sex", "m" ); } Setting any CVAR works fine, but while getting the value from any, the game crashes and throws me to the desktop. Not sure what the issue could be... Edit: This is the line that's crashing it: set( "playergen", get(STRING, "cvar_sex") );
eezstreet Posted August 17, 2015 Posted August 17, 2015 It looks like a bug on this line. It needs to allocate some memory first. Cerez likes this
Asgarath83 Posted August 17, 2015 Posted August 17, 2015 for playermodel and skin is easy:1 make the info_player_start when you start a level2 make a trigger_once around info_player_start with playeronly spawnflag3: make a script runned by trigger_once with usescript command into trigger_once or with a target_scriptrunner fired by trigger_once.into Icarus script make a script file called "Intro "that run at the start of level you can set this:SET_PLAYERMODEL "ahsoka"SET_SKIN "models/players/ahsoka/model_blue.skin"and buld the script in IBI file. put into scripts folder in a subfolder with name of map. for run the script use the command on trigger_once or target_scriptrunnerkey Usescriptvalue "mapname/intro"no code hacking required. the unique issue is if you make too much custom playermodel and skin changes into the level the savegames should crash. :\ Dusty and Cerez like this
Dusty Posted August 19, 2015 Posted August 19, 2015 ^You know a little bit about everything don't you Asgarath @@Cerez:Maybe it will come in handy for you, I believe there is a console command called "runscript". I've never tested it but I'm guessing it lets you run scripts without having to have the map trigger them.
Ramikad Posted August 19, 2015 Posted August 19, 2015 As far as I know, runscript only works with cheats enabled.
Cerez Posted August 19, 2015 Author Posted August 19, 2015 True and true. I am using runscript to run my script, but my main dilemma is with reading and storing the values of a CVAR in another variable currently. In order to be able to create some interactive scripting, I need to be able to get a currently set value and store it away for later use. The solution mentioned by @@redsaurus and @@eezstreet is closest to what I need, but unfortunately because of the programming bug getting a value is broken atm.
Asgarath83 Posted August 19, 2015 Posted August 19, 2015 True and true. I am using runscript to run my script, but my main dilemma is with reading and storing the values of a CVAR in another variable currently. In order to be able to create some interactive scripting, I need to be able to get a currently set value and store it away for later use. The solution mentioned by @@redsaurus and @@eezstreet is closest to what I need, but unfortunately because of the programming bug getting a value is broken atm.What you exactly need to do with interactive scripts? you can use the "declaire" on icarus for set a function name, the set parameter for assign to declaired function a temp value. and you can make an if \ else brank cycle for changing is value at second of some conditions. if you want an example of that, check the scripts of t1_danger map about the rescue of part of device for repair ship transport and leave planet of sand creature. the Objective completed and some events that remove or place the MD3 files of device part you take are setted with declaire, set, if and else function. they are not cvars, but with that system i make the following thing: - there is a tomb with a wraith ghost, there are 5 souls into the tomb. every souls is usable.at start of level, is declared a value souleated.souleated are setted as 0for every soul the reaver eating (taking the souls and using with use function - i make usables trigger_onces) any soul trigger the same script. into the script are setted that parameter:- play sound of soul devoured.- remove soul efx.- add to souleated value +1- unlock for player a force power.- add 20 health to player.so, when player eat 2 soul, he get more jump abilities. with 3 souls the push abilities, with 5 souls he unlock the saber and is used a force field that deny to player to leave the room. works like a charm. but is not a cvars function . but if you need, you can use also the declaire, set and if \ else functions for making storable values. @@Dusty a lot of everything, but i am not an expert of any thing i am not nice in coding like eezstreet, and i am not nice as mapper as szico. my competence i think can be the "general modding" without any specified field. the more good things i am good to do are the rigging of models, the frankensteining (but on 3d max, not on blender) a lot of reskinning and audio file manipulations. . Cerez and Dusty like this
Cerez Posted August 19, 2015 Author Posted August 19, 2015 Thanks Azy. I'm looking for a way to read current user choices/settings in the game because I need for my script to be able to toggle back to the original user settings, or use them as reference for future events. Many of these detailed settings are game controlled, and set in CVARs, so I need to be able to read the CVARs specifically, I think... But your suggestions are great for interactive scripting outside the scope of reading detailed user settings.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now