[0.9] Require crash

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

[0.9] Require crash

Post by rk84 »

Game crashes if I try to require file via console.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: [0.9] Require crash

Post by AlexPhoenix »

Where file is placed?
and how exactly you requare file?

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.9] Require crash

Post by rk84 »

AlexPhoenix wrote:Where file is placed?
and how exactly you requare file?
1)Right next to factorio.exe
filename test.lua

2)require "test"

Also. I just noticed I use 32 bit zip package (usb memory stick) in 64 bit Win 7. Seems to work fine overall.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9] Require crash

Post by kovarex »

So I fixed it, it returns error message instead of the crash.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.9] Require crash

Post by rk84 »

I would like to add that remote calling this also cause a crash.

Code: Select all

remote.addinterface("console++",
{
  test = function()
    return require("test")
  end
})
test.lua were in both, Win32 and mod's folder.
test.lua: creates local table, adds some functions to table and returns the table.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: [0.9] Require crash

Post by cube »

rk84 wrote:I would like to add that remote calling this also cause a crash.

Code: Select all

remote.addinterface("console++",
{
  test = function()
    return require("test")
  end
})
test.lua were in both, Win32 and mod's folder.
test.lua: creates local table, adds some functions to table and returns the table.
Thanks for noticing. These corner cases are pretty annoying :-) Do you know if this worked in 0.8.x?
I have no idea what I'm talking about.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.9] Require crash

Post by rk84 »

cube wrote:Do you know if this worked in 0.8.x?
I get console message in 0.8.8

Code: Select all

Cannot execute command. Error: attempt to index a string value
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: [0.9] Require crash

Post by cube »

So I checked it now -- After kovarex's change the crash disappeared even with the remote.call scenario. On the other hand when remote.call was used from a mod, requires used in the interface would almost never work as intended. So I changed the error message and completely disabled requires in interfaces for 0.9.2
I have no idea what I'm talking about.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.9] Require crash

Post by rk84 »

This is starting to be more of interface bug report than require, but still I will continue here.

there is problem when returning function(s) in interface. I remote call these in console. Returning number or string or number/string in table works, but functions do not.

This gives error "attempt to index a string value"

Code: Select all

test = function()
  return {function() game.player.print("functest") end}
end
This returns string "test"

Code: Select all

test = function()
  return function() game.player.print("functest") end
end
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: [0.9] Require crash

Post by AlexPhoenix »

from https://forums.factorio.com/wiki/inde ... interfaces
The interface functions can take only primitive types and tables as variables. The same holds for return values. The reason for this is that the scripts are running in different lua states and there is no easy way of passing more elaborate data (functions, rich Factorio objects - Lua Entity, etc.) around. Passing simple function callbacks is very powerful mechanism and might be implemented in some way in the future.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.9] Require crash

Post by rk84 »

Ah I forgot that.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Post Reply

Return to “Resolved Problems and Bugs”