New API Docs website

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 279
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: New API Docs website

Post by Muppet9010 »

The process that a mod makes a request via the API (either function or to get/set a field) would be helpful. I got the below answer via Discord from Bilka that all LuaObject instances returned to my mod from the API have 0 field data. So for UPS optimised mods we should really be caching every field's value where possible when reused for lowest UPS cost. Especially important when on_tick events are being used.
Bilka:
Every single thing you access on a LuaObject is given to you upon request, nothing comes with the original object
I had assumed that the simple value fields (ints, strings) where coming back with the LuaObject and it was only references to other LuaObjects that were obtained on access.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3716
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: New API Docs website

Post by DaveMcW »

On LuaTransportLine and probably other pages, the index() and length() operators are not defined properly.
operator length :: uint [R] Get the number of items on this transport line.
operator index :: LuaItemStack [R] The indexing operator.
Compare to the old API:
operator # :: uint [R] Get the number of items on this transport line.
operator [] :: LuaItemStack [R] The indexing operator.
Hornwitser
Fast Inserter
Fast Inserter
Posts: 214
Joined: Fri Oct 05, 2018 4:34 pm
Contact:

Re: New API Docs website

Post by Hornwitser »

I made a video to demonstrate just how badly the new site design performs on my phone compared to the old one, and with the box shadows removed.

https://youtu.be/xjCwI-8wy2g

This is also how the main site, blog, and mod portal performs on my phone. In my opinion it's not a great look for a game that touts as being highly optimized to have a site design this slugging. And again, you can get these fancy looking borders without performing like a dumpster fire using border images instead of abusing box shadows.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: New API Docs website

Post by curiosity »

So, today the way to obtain a link to method/property from its entry has changed from a neat link on the name itself to a pretentiousfancy little chain icon. Can we have the old one back? Nothing prevents having both.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3716
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: New API Docs website

Post by DaveMcW »

curiosity wrote: Thu Jan 13, 2022 8:08 pm So, today the way to obtain a link to method/property from its entry has changed from a neat link on the name itself to a pretentiousfancy little chain icon. Can we have the old one back? Nothing prevents having both.
The name in the method list at the top of the page is still a link and works like it always does. The chain icon at the bottom of the page is just a bonus.

The confusing part is that the name+link at the top of the page is the same color as the name+description at the bottom of the page, but only one of them is clickable.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: New API Docs website

Post by curiosity »

DaveMcW wrote: Fri Jan 14, 2022 12:41 am The name in the method list at the top of the page is still a link and works like it always does. The chain icon at the bottom of the page is just a bonus.

The confusing part is that the name+link at the top of the page is the same color as the name+description at the bottom of the page, but only one of them is clickable.
But you have to scroll to the top. What I mean is the name "at the bottom of the page", as you put it, was also a link and now isn't.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5267
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: New API Docs website

Post by Klonan »

curiosity wrote: Thu Jan 13, 2022 8:08 pmNothing prevents having both.
I was having a problem with it, often you want to copy-paste exact names of variables and events, and when it was a link it would keep jumping the page around instead of letting me select it and copy
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: New API Docs website

Post by ptx0 »

Klonan wrote: Fri Jan 14, 2022 6:00 pm
curiosity wrote: Thu Jan 13, 2022 8:08 pmNothing prevents having both.
I was having a problem with it, often you want to copy-paste exact names of variables and events, and when it was a link it would keep jumping the page around instead of letting me select it and copy
so put a little clipboard icon and copy it when you click THAT.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: New API Docs website

Post by curiosity »

Klonan wrote: Fri Jan 14, 2022 6:00 pm I was having a problem with it, often you want to copy-paste exact names of variables and events, and when it was a link it would keep jumping the page around instead of letting me select it and copy
That's a good point, though in my experience links only cause issue when you want to select in the middle of them. Shouldn't matter when selecting the entire link text.
coderpatsy
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Tue Apr 17, 2018 11:45 pm
Contact:

Re: New API Docs website

Post by coderpatsy »

Klonan wrote: Fri Jan 14, 2022 6:00 pm
curiosity wrote: Thu Jan 13, 2022 8:08 pmNothing prevents having both.
I was having a problem with it, often you want to copy-paste exact names of variables and events, and when it was a link it would keep jumping the page around instead of letting me select it and copy
I find browser extensions like Copy Link or Copy Link Text to be invaluable. Also, holding alt will allow you to select text without following links (or sending JS events for that click at all I think). I'm not arguing to change the site back, just saying.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1726
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: New API Docs website

Post by Pi-C »

coderpatsy wrote: Sat Jan 15, 2022 7:40 am I find browser extensions like Copy Link or Copy Link Text to be invaluable.
Thanks for the hint, I've just installed Copy Link Text! :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5267
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: New API Docs website

Post by Klonan »

coderpatsy wrote: Sat Jan 15, 2022 7:40 amhout following links (or sending JS events for that click at all I think).
Invaluable tip! Thank you! Actually I have this problem quite frequently and this will optimize my time
(They say perfection is just doing a lot of little things right)
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: New API Docs website

Post by curiosity »

coderpatsy wrote: Sat Jan 15, 2022 7:40 am Also, holding alt will allow you to select text without following links (or sending JS events for that click at all I think).
Good to know. Would have been good for this if it also didn't download the link.
coderpatsy
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Tue Apr 17, 2018 11:45 pm
Contact:

Re: New API Docs website

Post by coderpatsy »

curiosity wrote: Fri Jan 21, 2022 3:07 pm Good to know. Would have been good for this if it also didn't download the link.
Ah, it doesn't download if you click and drag. Just a click does the download.
curiosity
Filter Inserter
Filter Inserter
Posts: 470
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: New API Docs website

Post by curiosity »

coderpatsy wrote: Fri Jan 21, 2022 4:28 pm Ah, it doesn't download if you click and drag.
Does for me.
Katharsas
Inserter
Inserter
Posts: 27
Joined: Sat Nov 10, 2018 1:45 am
Contact:

Re: New API Docs website

Post by Katharsas »

I just disabled box shadows, gives me about 7 more FPS (Firefox) when scrolling (but its still above 150fps average on an i7 7700k and GTX 1060), but more importantly it just feels smoother.

With original page, it sometimes stutters/hitches when you start scrolling. With the shadows disables everything is instant, like playing a game at 0 input lag compared to mediocre input lag.

I used Stylus to edit the CSS:

Code: Select all

* {
    box-shadow: none !important;
}
Hornwitser
Fast Inserter
Fast Inserter
Posts: 214
Joined: Fri Oct 05, 2018 4:34 pm
Contact:

Re: New API Docs website

Post by Hornwitser »

Katharsas wrote: Sun Jan 23, 2022 10:57 pm I just disabled box shadows, gives me about 7 more FPS (Firefox) when scrolling (but its still above 150fps average on an i7 7700k and GTX 1060), but more importantly it just feels smoother.
I already demonstrated this in the video I posted in previous post. But unlike your GTX 1060, my phone dips to 1fps scrolling and can take more than 10 seconds to render the page after scrolling far.

I made a modifying proxy for the lua api site that removes the box shadows for this video, it's still up at http://lua-api.hornwitser.no/latest/
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 279
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: New API Docs website

Post by Muppet9010 »

On the main page (https://lua-api.factorio.com/latest/index.html) the Classes header isn't clickable, but the Events header further down the page is.
Capture.PNG
Capture.PNG (63.97 KiB) Viewed 5072 times
There is the Classes page that I assume the header should link to: https://lua-api.factorio.com/latest/Classes.html
Xorimuth
Filter Inserter
Filter Inserter
Posts: 695
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: New API Docs website

Post by Xorimuth »

Can you add `spellcheck="false"` to the search input please? When I search for words (or parts of words) it suggests different words, and when I click away (on the search result) it automatically 'corrects' the word, which then changes the search results, so I don't get sent to the page I clicked on :(

See the following video (safari 15.4):
Screen Recording 2022-03-29 at 18.59.57.mp4
(79.58 KiB) Downloaded 84 times
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 249
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: New API Docs website

Post by Therenas »

Muppet9010 wrote: Wed Feb 09, 2022 8:26 pm On the main page (https://lua-api.factorio.com/latest/index.html) the Classes header isn't clickable, but the Events header further down the page is.
Capture.PNG
There is the Classes page that I assume the header should link to: https://lua-api.factorio.com/latest/Classes.html
You are absolutely right. I have some bigger changes for that page in mind, but I don't see why I shouldn't just quickly fix this. Thanks for the report, fixed for the next release.
Post Reply

Return to “Modding discussion”