Besiege

Besiege

Logic extensions mod
188 Comments
66866806 Apr 18 @ 6:19pm 
Why can't I see the "LERP" button any where
酒漆9793 Jul 9, 2024 @ 5:35am 
伟大,无需多言。
thomasrolling Jul 7, 2024 @ 6:18am 
Great MOD,but the LERP function in ANGLOMETER stop work in LEVEL EDITOR, the option of
LERP is missed. I dont know why
Lambda  [author] Jun 19, 2024 @ 2:18pm 
@憨憨, in JS everything is an object. So just
var obj = { field1: 123, field2: 'text1' };
obj.field2 = 'text2';
is ok.
憨憨 Jun 17, 2024 @ 9:41pm 
Great MOD !!! is there a way for me to implement data structures like array or class?
Lambda  [author] May 18, 2024 @ 11:55am 
@Jinges, unfortunately it works only in single-player mode now. 1.26 update have broken multiplayer support for this mod and I see no way to fix it, like stated in first lines of mod description.
You can run modded machines in default sandboxes and game levels, but cannot run them in multiverse.
Lambda  [author] May 18, 2024 @ 11:51am 
@No_Lives_Matter, maybe some IDs for workshop have changed. Try open steamapps folder in windows exprorer and search for "00-helloworld.js" in top-right corner. Explorer should find this example. Then just go to file location, it will be mod's folder with example scripts.
No_Lives_Matter May 13, 2024 @ 11:08pm 
The link to the example js codes is not working for me :/
where could a lad find some codes?
Jinges May 13, 2024 @ 7:27am 
Does this mod still work in v1.26? either i installed it wrong or something is broken?
Lambda  [author] May 10, 2024 @ 12:24pm 
@Cay, I didn't understand what do you mean by playing maps offline and why it could break. This whole game is not online.
Cay May 6, 2024 @ 1:52am 
Is there a way to play maps from the editor offline? (so the mod doesn't break) Great mod, regardless!
Lambda  [author] Feb 3, 2024 @ 10:03am 
@noob.oel, it seems that after the last update devs have internally split block prefabs into single-player and multi-player copies. Since key mapping is heavily integrated in game code, this mod had to rewrite vanilla blocks in single-player prefab collection to implement ExtKey logic.

To fix this issue with multiplayer mod has to rewrite network blocks prefabs, but their collection is made inaccessible by devs. So I guess now this mod is impossible in multiplayer. Forever.
noob.oel Jan 25, 2024 @ 1:35pm 
Thank your for your excellent work! However, I think there is a problem with the level editor. Whenever I go into either level editor or multiplayer with level editing enabled, LERP options disappear. Is there a fix to this? thx.
Lambda  [author] Aug 23, 2023 @ 11:15am 
@[NMG] ConfusedMaster, there is a rather old mod called "Joystick Mod" here in steam workshop. It is designed exactly for your usecase. I haven't used it though since I have no joystick.
[NMG] ConfusedMaster Aug 21, 2023 @ 4:13am 
this mod would be the perfect foundation for gamepad/joystick-support! imagine how smooth you could control your machines.
Lambda  [author] Aug 6, 2023 @ 2:17am 
@jiangziyi326, thanks.
You can find modding documentation in your Besiege installation under <steam_folder>\steamapps\common\Besiege\Besiege_Data\Documentation\Modding.pdf.
This doc is not very easy to understand, but it is all I used. You may also need unity docs and use visual studio hints during developement. Logic Extensions mod is opensource, so you can use it as reference.
jiangziyi326 Jul 17, 2023 @ 2:39am 
Excellent work, I also like to become a mod developer like you, but there is little information about it online, could you give me some advice? Like some development routes, notes,guides.
In reddit also has similar questions to mine:
https://www.reddit.com/r/Besiege/comments/7vnca0/anyone_interested_in_making_a_basic_mod_guide/
thank you sincerely if you would help!
Lambda  [author] Jun 18, 2023 @ 9:53am 
@♣Tibruscus♣, first of all, you can't get angle of a sensor block. Angle is retrieved through reading anglometer. You can lookup result of readSensor() on github wiki.
Second - if you need only angle itself, it's easier to just use in() from LERPed anglometer and multiply result by anglometer's range (ex. 360).
Third - well, there is a small bug: for some reason readSensor for anglometer now works only when they are connected by message key and not working for normal keyboard keys. Example working setup is:
- Pinned starting block -> steering block -> anglometer; CPU block
- Anglometer setup: LERP, min = 0.001, max = -0.001, emulate message = MSG (not a keyboard key)
- CPU setup: pio00 = MSG, code =

function checkSensor() {
var info = readSensor(0);
if (info)
print(info.quaternion);
setTimeout(1, checkSensor)
}
checkSensor();

This prints to console anglometer's rotation quaternion every 1 second. But in fact quaternions are not easy to deal with.
♣Tibruscus♣ Jun 17, 2023 @ 10:36pm 
maybe im completely bugging, but i cant seem to for the life of me figure out how to use the sensor api. ive tried things previously mentioned throughout this comment section but non of it seems to work. can you give me an example of how to get the angle of a sensor block with said code?
Apophis May 19, 2023 @ 4:43pm 
I managed to make PID controlled active suspension system. Great mod. A little hard to grasp at first glance, but it turns out to be quite handy and intuitive. Keep up the good work mate :)
Lambda  [author] Mar 19, 2023 @ 7:21am 
@Grendix, as mentioned in the description, after one of the game updates "All numeric ExtKey values will be converted to messages and will be editable in corresponding menu. External text input is removed." You can edit them in default Besiege "message" keys mapping. Screenshots with extInputs were taken before this update.
This mod was created before such functionality appeared in-game and later I had to merge dev's "message" keys and mine "virtual keys" into default mechanism. Now this mod is useful for LERP mechanics and CPU block, but it is not necessary if you need virtual keys only.
Grendix Mar 13, 2023 @ 2:27pm 
i can't set custom utput/input addres there is no additional inputs in tool frame
Lambda  [author] Jan 18, 2023 @ 10:54am 
@Akwaena, check "OPEN CONSOLE" option in game controls settings. It is "Ctrl+K" by default.
Akwaena Jan 16, 2023 @ 10:20am 
How can I open the console?
Lambda  [author] Dec 2, 2022 @ 12:01pm 
@Meraf, I guess it works as expected. Anglometer block *always* has start and end angles, let's call them S and E. When you set them in lerp mode, there will be 3 zones:
1) angle in [0..S) => output = 0
2) angle in [S..E] => output is LERP of angle between S and E in range [0..1]
3) angle in (E..360] => output is 1
If you pass line of 0 degree, you go from range 3 to range 1 dropping output from 1 to 0.
I've made a simple image to illustrate this:
https://steamcommunity.com/sharedfiles/filedetails/?id=2896488922
In case you set S == E, nothing changes - you still have 2 angles, but zones 1 and 3 have zero width. So if you rotate clockwise you will get output 0, slowly climbing up to 1 at full rotation, and after passing 0 degree it will drop back to 0. If you rotate counter-clockwise, you will immediately get 1 and then the opposite logic.
If you want some other behavior, you have to utilize CPU to convert this output to some kind of sinus you want.
Merhaf Dec 1, 2022 @ 10:48pm 
Anglometer outputs Lerp values even at angles not selected.
and It outputs a value unconditionally when it rotates counterclockwise.
Lambda  [author] Dec 1, 2022 @ 9:45am 
@Merhaf, without details I cannot get what exactly is wrong.
Merhaf Nov 29, 2022 @ 11:51am 
I can't explain in detail, but Anglometer is weird. Could you please check?
zzzzzxxc Feb 2, 2022 @ 12:31am 
THANKS!!!
fried chicken Jan 15, 2022 @ 7:14am 
Great work! It's not an easy thing to solve all the problems in such a short time, thank you!
Lambda  [author] Jan 15, 2022 @ 6:07am 
[UPDATE 2] After some research I've found a way how to make new "message" keys compatible with this mod. Modified logic is:
1) Once old machine, built with this mod, is loaded, it's keys will be silently converted to new Besiege keys with message support. Before overwriting saved machine you may back-up it just in case something goes wrong with conversion.
2) All numeric ExtKey values will be converted to messages and will be editable in corresponding menu. External text input is removed.
3) ExtKey (ones in automation blocks and CPU) simulates BOTH selected normal keys AND message keys at the same time. No matter what position of corresponding switch in mapper is set.
4) Besiege keys (in all blocks except automation blocks) in contrast react ONLY the mode you selected (key OR message).
5) If ExtKey generates LERP [0..1] value output, it can be accepted by modified blocks, listed in mod description, not only by key, but by message also.

@fired chicken, I think this will work.
fried chicken Jan 15, 2022 @ 2:44am 
hi, I've been using this mod since its release, and your variable system really helps me a lot. But now the in-game variable system supports any variable names -- in English or even other languages, make it much easier to remember the usage of variables. I will really appreciate you if the two systems can be compatible with each other!
Lambda  [author] Jan 13, 2022 @ 4:33pm 
[UPDATE]
I've made a small update to support new LogicGate modes released in game yesterday.
BTW, it seems game is slowly moving towards supporting text keycodes by itself, without this mod - but keys still lack support of floating-point key values. Also it seems that in-game default "message" keys cannot be combined with standard keyboard ones in the same control, so I cannot migrate to in-game defaults (yet?). Thus in-game "message" key input will not work with this mod, clicking on corresponding button will have no result.
日常 Dec 20, 2021 @ 6:30am 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:steamhappy::steamthumbsup::steamhappy:
Lambda  [author] Dec 19, 2021 @ 11:10am 
@日常, I've uploaded new version with fix, hoping nothing else is broken by this change.
日常 Dec 19, 2021 @ 6:57am 
thank for your patience and kindness.your mod is well well helpful and useful.
my question of the toggle mode of the Logic Gate is that when i enable this mode i can't use the Logic Gate as easy as before.so the toggle mode of the Logic Gate is approximately unable.
But the other functions is going well.hope hear form you soon,cheers.:steamhappy:
Lambda  [author] Dec 18, 2021 @ 5:36pm 
@日常, hello. Sorry, I did not understand what do you mean, Could you please post a more detailed description or a screenshot (using some external resource) of what is going wrong?
日常 Dec 18, 2021 @ 5:49am 
Hello,thank for your mod.but i have some problem.when i enable this mod,the toggle mode is unable .hope hearing from you soon,cheers.
Дак Aug 27, 2021 @ 11:36am 
Thanks!
Lambda  [author] Aug 27, 2021 @ 10:52am 
@Дак, mod is based on Jint: https://github.com/sebastienros/jint
But it was patched to be able to run in paleozoic-era Unity, used in Besiege. Also some patches were applied to implement Gas concept.
Дак Aug 27, 2021 @ 10:30am 
I remember that you left a link to the C# javascript implementation that works in Unity. I may be blind, but could you please give me this link?
寝たい Jul 27, 2021 @ 4:53pm 
@Lambda, I see. Thanks a lot!
Lambda  [author] Jul 27, 2021 @ 10:57am 
@寝たい, I cannot check it on Mac, but on Windows everything works like in normal text editor. If it does not work, you can try running game in windowed mode, maybe this will help. Also using window mode you may consider writing code in any other text editor and then copy-pasting it into CPU editor in game.
寝たい Jul 26, 2021 @ 4:08pm 
A dumb question, how do I change lines when editing code in a CPU block (enter/return seems not working)? Also arrow keys cannot move the cursor when editing. Is this an intended behavior?
I'm using a Mac, if it matter. Thanks!
Lambda  [author] Jul 24, 2021 @ 12:07pm 
@SakiGenji, yes, you can get coordinates of altimeter block with cpu api readSensor().
SakiGenji Jul 24, 2021 @ 2:05am 
Can I use this mod to get the coordinates in the game?
Lambda  [author] Jul 15, 2021 @ 2:52pm 
@Хубабубовец, yes, glowing E indicates unhandled exception in JS code.
Густосмыл Jul 15, 2021 @ 2:40pm 
@Lambda, letter "E" on the CPU unit means error, right?
Густосмыл Jul 15, 2021 @ 2:28pm 
@Lambda, k, ty, gonna give it a try
Lambda  [author] Jul 15, 2021 @ 1:37pm 
@Хубабубовец, if you don't want to "see" enemies through other objects, but you want turret to fire only when object is enemy - you can just read object type with readSensor() api and make a decision to fire or not just with normal if () {} statement in CPU. But if sensor's field of view contains both an enemy and a tree, and the tree is closer to sensor, sensor will detect the tree, not the enemy.