jdf221 / CC-WirelessPeripheral

An implementation of the Computer Craft peripheral API allowing the use of wireless modems
MIT License
13 stars 4 forks source link

Bigger Reactors #7

Open PedroAugusto1907 opened 1 year ago

PedroAugusto1907 commented 1 year ago

Hi! I'm having this error image (6) when try to connect Bigger Reactors Installer: https://pastebin.com/MiwX1rFf Controller: https://pastebin.com/KJwPLGWa Sorry for my bad english and thanks for your attention.

jdf221 commented 1 year ago

Will take a look at this when I get home later. Odd error...

jdf221 commented 1 year ago

Ok I found the issue. Bigger Reactors provides peripheral API methods that return objects that contain functions.

Rednet/wireless modems only support text transfer, so when you call a method on the peripheral and it returns for example {getPowerLevel=function, getChargeRate=function} WPP tries to convert that whole object into a string to send it over Rednet. Obviously that's not possible since you can't convert a function to a string.

Don't have the time tonight to fix it but I have an idea for how to fix it. Either going to create a "cached mapping" of returned functions and assign an ID to each function. Or I'll just have the functions recall their parent peripheral method each time they're called.

2nd way isn't ideal (because recalling the parent method could cause side effects) but I'm leaning towards it because the 1st way would create a permanent "cache" that would never be garbage collected (or whatever goes on in LUA lol) and could become an issue since WPP is meant to be ran indefinitely.

Will work on it tomorrow.

jdf221 commented 1 year ago

Ok @PedroAugusto1907 give this new version a try:

wget https://raw.githubusercontent.com/jdf221/CC-WirelessPeripheral/jdf221-patch/wpp.lua?token=noCachePls wpp

I haven't tested it with the actual Bigger Reactors mod so no clue if it'll work lol. I don't love how the code turned out but hopefully it'll work for you.

You will need to update the "wpp" script on all of your computers.