Search found 16 matches

by Kruparker
Thu Jul 07, 2016 2:52 pm
Forum: Modding help
Topic: how to know if item has inventory (ItemWithInventory ) ?
Replies: 2
Views: 1468

Re: how to know if item has inventory (ItemWithInventory ) ?

indeed, that's a way to do it, thank's

I'm not used to throw an exception to make an "if", but why not. =)
by Kruparker
Thu Jul 07, 2016 12:51 pm
Forum: Modding help
Topic: how to know if item has inventory (ItemWithInventory ) ?
Replies: 2
Views: 1468

how to know if item has inventory (ItemWithInventory ) ?

Everywhere on API doc for LuaItemStack ,
members refer to " Can only be used if this is ItemWithInventory "

but there's no
ItemWithInventory :: Booleen [Read-only]
return true / false

get_inventory
Should
Return value
or nil if there is no inventory with the given index.

but Crash because ...
by Kruparker
Thu Jul 07, 2016 12:24 pm
Forum: Wiki Talk
Topic: Missing item stat: inventory stack size
Replies: 1
Views: 2195

Re: Missing item stat: inventory stack size

item stack size is available through prototype.
http://lua-api.factorio.com/0.13.6/LuaI ... stack_size

Code: Select all

 local item  = inventory[some_index]
item.prototype.stack_size -- do whatever you want here
by Kruparker
Mon Jun 27, 2016 8:35 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button

Sorry, I didn't see your post before (I was kind of busy).

If I have enough time, I could do something for the end of the week (and if 0.13 not breaks everything)

If you think you can do it yourself (better / before me), just do it. I won't complain (just tell me so we are not 2people working on ...
by Kruparker
Tue May 31, 2016 5:25 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button


require "util"
copy = util.table.deepcopy(table)

This creates a complete copy of a table, not just another reference. If you change a value in copy, it doesn't change it in table.


Yeah : It Works !
..
...
....
MY ASS ! >.<

It's now official I hate LUA.



for i=1, inventorySize do
if ...
by Kruparker
Mon May 30, 2016 10:16 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button

thanks, you seem to be my savior, I tried "standard" deepcopy method found on the web but they all crashed my game.

Code: Select all

-- don't copy factorio rich objects
could be what crashed my game.

I'll try this tomorrow, thanks
by Kruparker
Mon May 30, 2016 5:14 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button

hummm so opened_self was player inventory opened... not very clear >.<
Thanks !

I'll search if it's possible to add the button to the existing inventory gui.
At least, I could show the button when inventory is opened, hide it when inventory is closed.
and maybe add a configuration screen with a ...
by Kruparker
Mon May 30, 2016 2:46 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button

would it be possible to make it sort when you close your inventory?

I don't think so.
I didn't find any event related to inventory (or key press), this is why the button is always visible.
You can click it whenever you want to sort your inventory.
Would it work as a timer? Sorting at set ...
by Kruparker
Sun May 29, 2016 2:51 pm
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button


When someone presses the button, you'll get a player_index. You can put this into game.players[player_index] instead of game.players[1].


on_gui_click

Called when LuaGuiElement is clicked.
Contains
element :: LuaGuiElement: The clicked element.
player_index :: uint: The player who did the ...
by Kruparker
Sun May 29, 2016 11:13 am
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

Re: [MOD 0.12.33+] Sort Inventory button

sporefreak wrote: would it be possible to make it sort when you close your inventory?
I don't think so.
I didn't find any event related to inventory (or key press), this is why the button is always visible.
You can click it whenever you want to sort your inventory.
by Kruparker
Sun May 29, 2016 1:36 am
Forum: Mods
Topic: [MOD 0.12.33+] Sort Inventory button
Replies: 13
Views: 7853

[MOD 0.12.33+] Sort Inventory button

Hi,
here's a little mod to sort your inventory (group items, stack them)
only works for your main inventory

Because the always sorted option annoy me, but sometimes, I want to sort my items.

Type: Mod
Description: Add a 'S' button in top left corner to sort your inventory
License: modified MIT (my ...
by Kruparker
Thu May 26, 2016 6:04 pm
Forum: Mods
Topic: [MOD 0.12.12] Clock
Replies: 10
Views: 11645

Re: [MOD 0.12.12] Clock

Okay, after some test, I dropped dropped the util.formattime function because it doesn't count hours, so I've written my own function, and I've finished with this :

@ bioxz : You can use everything in your own mod, or some parts only, or whatever you want.

@ steinio : There is no way to get ...
by Kruparker
Thu May 26, 2016 10:07 am
Forum: Mods
Topic: [MOD 0.12.12] Clock
Replies: 10
Views: 11645

Re: [MOD 0.12.12] Clock

indeed, there's a formattime function in util.lua

but it converts ticks to time. I don't see how we can use it here to display ingame day time.
in game day time (game.daytime) is not a value in ticks but a float from to 0 to 1 where 0 is midday (afternoon begins) and 1 is (also) midday (morning ...
by Kruparker
Wed May 25, 2016 6:26 pm
Forum: Mods
Topic: [MOD 0.12.12] Clock
Replies: 10
Views: 11645

Re: [MOD 0.12.12] Clock

Hi,
thanks for your nice, small but very usefull little mod.

I did some "benchmarks" and found an other less time consuming function. It's not so big, but it's always good to take.

here the full modified version of your code : bench commented at the end

edit : code is also modified to update only ...

Go to advanced search