BoneTown
此社区中心标记为“仅限成人”。您看到此中心是因为您已将偏好设置为允许此类内容。
评价数不足
simple script tutorials to learn some bases scripting
由 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 !
   
奖励
收藏
已收藏
取消收藏
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 条留言
Korvus-Tytan 2023 年 8 月 2 日 上午 2:12 
does this work anymore i press the SHIFT AND ~ and nothing comes up
KoZx 2021 年 11 月 14 日 上午 1:00 
Is it possible to make my character walk and sit too with bind?
KoZx 2021 年 11 月 13 日 上午 3:07 
So i can put it all only in one .cs file? Thank you!
Codeman02Fr  [作者] 2021 年 11 月 11 日 下午 12:22 
put that for each accessory id in a *.cs file in the game/mod folder
Codeman02Fr  [作者] 2021 年 11 月 11 日 下午 12:20 
GlobalActionMap.bindCmd(keyboard, "numpad0", "gamechar.hideaccessory(1);", "Descr: Hide accessory 1");
GlobalActionMap.bindCmd(keyboard, "ctrl numpad0", "gamechar.Showaccessory(1);", " Descr : show accessory 1");
KoZx 2021 年 11 月 11 日 下午 12:01 
@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  [作者] 2021 年 11 月 11 日 上午 7:07 
KoZx> can you explain i don't understand your question
KoZx 2021 年 11 月 8 日 上午 9:03 
how can i bind the gamechar.hideaccessory and showaccessory?
BABY VEIN 2021 年 10 月 3 日 上午 7:54 
ahh okay
Codeman02Fr  [作者] 2021 年 10 月 3 日 上午 5:59 
currently delayed because i am coding some utils