BoneTown
This Community Hub is marked as 'Adult Only'. You are seeing this hub because you have set your preferences to allow this content.

BoneTown

Not enough ratings
simple script tutorials to learn some bases scripting
By Codeman02Fr
well i decided to help others to lean how to script the game.
this can be a local mod for you only or you can also make it a workshop mod to share with others and make it even easier to install/uninstall to others via workshop.

so i will add some simple scripts here (that people asked for in the game threads) with comments in code.
Feel free to make it a workshop mod !
   
Award
Favorite
Favorited
Unfavorite
step 1 : bind a key to a function to increase the player speed
1 - create a file called Myspeedmod.cs in your /bonetown/game/Mods/ folder
2 - put this code in it and save it, next time you load the game it will be compiled and loaded automatically
3 - load the game, load your mission and press the "numpad +" key to test

// our function to be called to set the speed to value 3 function ChangePlayerSpeedPlus() { %tChar = ServerConnection.GameCharacter; //get the player object from engine if(%tChar !$= "" && %tChar !$= "0") //ensure the mission and player object are loaded !!! { %tChar.modifySpeed(3, 1); // set to speed to 3 or more ,change the value to test XD } } GlobalActionMap.bind(keyboard, "numpadadd", "changeplayerspeedplus", "Increase the player speed");
step 2 : add a decrease player speed function
1 - create a file called Myspeedmod.cs in your /bonetown/game/Mods/ folder
2 - put this code in it and save it, next time you load the game it will be compiled and loaded automatically
3 - load the game, load your mission and press the "numpad +" and "numpad -" keys to test

//declare our global variable to store the speed, it will increase each time you press the keys $myplayerspeed = "1"; //we start at player speed =1 $myspeedsteps = 0.1; // we want to add/remove 0.1 to the player speed at each key press // then our function to be called to increase speed: function ChangePlayerSpeedPlus() { %tChar = ServerConnection.GameCharacter; //get the player object from engine if(%tChar !$= "" && %tChar !$= "0") //ensure the mission and player object are loaded !!! { if($myplayerspeed < 6) //make sure we are not already too quick in game { $myplayerspeed = $myplayerspeed + $myspeedsteps ; // this allow to auto increase the value each time the function is called by pressing the keys %tChar.modifySpeed($myplayerspeed , 1); // set our new speed } } } // then our function to be called to decrease speed: function ChangePlayerSpeedMinus() { %tChar = ServerConnection.GameCharacter; //get the player object from engine if(%tChar !$= "" && %tChar !$= "0") //ensure the mission and player object are loaded !!! { if($myplayerspeed > 0.1) //make sure we are not already too slow in game (no negative value) { $myplayerspeed = $myplayerspeed - $myspeedsteps ; //decrease our value by 0.1 // this allow to auto decrease the value each time the function is called by pressing the keys %tChar.modifySpeed($myplayerspeed, 1); // set our new speed } } } GlobalActionMap.bind(keyboard, "numpadadd", "changeplayerspeedplus", "Increase the player speed"); // add a key to increase speed GlobalActionMap.bind(keyboard, "numpadminus", "changeplayerspeedminus", "Decrease the player speed"); // add a key to decrease speed
step 3 : create a script to make power permanent
1 - create a file called MyDRUGSmod.cs in your /bonetown/game/Mods/ folder
2 -put this code in it and save it, next time you load the game it will be compiled and loaded automatically
3 - load your game, load your save or new game and press "numpad 0" key to test
//declare our global variable to store the drug name $MyDrugEffect = $Character::DRUGINFO_PEYOTE; // List of available drug effects that you can use : // $Character::DRUGINFO_BEER // $Character::DRUGINFO_WEED // $Character::DRUGINFO_SHROOM // $Character::DRUGINFO_PEYOTE //(invisibility) // $Character::DRUGINFO_TOAD // $Character::DRUGINFO_CRACK //Now we add a function to set the drug effect permanent: function setMYDrugEffectPermanent() { %tChar = ServerConnection.GameCharacter; //get the player object from engine in our local var if(%tChar !$= "" && %tChar !$= "0") //ensure the mission and player object are loaded !!! { %tChar.setDrugEffectPermanent($MyDrugEffect, true); // set peyote drug power permanent (invisibility) %tChar.setDrugEffect($MyDrugEffect, true); //enable it ingame like if you used it } } // add a key to set drug permanent here we use "p" on keyboard //Note : as it is a test key and a global one , make sure to not have other mods using the same key in the /mods/ folder GlobalActionMap.bind(keyboard, "numpad0", "setMYDrugEffectPermanent", "set peyote drug permanent");
step 4 : Simple script to re-enable the ingame console.
1 - create a file called Mykeysmod.cs in your /bonetown/game/Mods/ folder
2 - put this code in it and save it, next time you load the game it will be compiled and loaded automatically
3 - load the game, load your mission and press the "sift + tilde" key to test

// our function to assign the function to a key : GlobalActionMap.bind(keyboard, "shift tilde", "toggleConsole", "toggle the console visibility (on/off)");
13 Comments
Korvus-Tytan 2 Aug, 2023 @ 2:12am 
does this work anymore i press the SHIFT AND ~ and nothing comes up
KoZx 14 Nov, 2021 @ 1:00am 
Is it possible to make my character walk and sit too with bind?
KoZx 13 Nov, 2021 @ 3:07am 
So i can put it all only in one .cs file? Thank you!
Codeman02Fr  [author] 11 Nov, 2021 @ 12:22pm 
put that for each accessory id in a *.cs file in the game/mod folder
Codeman02Fr  [author] 11 Nov, 2021 @ 12:20pm 
GlobalActionMap.bindCmd(keyboard, "numpad0", "gamechar.hideaccessory(1);", "Descr: Hide accessory 1");
GlobalActionMap.bindCmd(keyboard, "ctrl numpad0", "gamechar.Showaccessory(1);", " Descr : show accessory 1");
KoZx 11 Nov, 2021 @ 12:01pm 
@Codeman02Fr there is a command you type in the console "gamechar.hideaccessory(1-9)" and "gamechar.showaccessory(1-9)" it hides and shows clothes on your character, how can i bind them to keyboard so i dont have to type it in console everytime
Codeman02Fr  [author] 11 Nov, 2021 @ 7:07am 
KoZx> can you explain i don't understand your question
KoZx 8 Nov, 2021 @ 9:03am 
how can i bind the gamechar.hideaccessory and showaccessory?
BABY VEIN 3 Oct, 2021 @ 7:54am 
ahh okay
Codeman02Fr  [author] 3 Oct, 2021 @ 5:59am 
currently delayed because i am coding some utils