I currently have:
Edited by KingofGamesYami, 07 May 2014 - 09:35 PM.
Posted 06 May 2014 - 09:30 PM
Edited by KingofGamesYami, 07 May 2014 - 09:35 PM.
Posted 06 May 2014 - 09:57 PM
for k, v in pairs(msg[4]) do per[k] = modem.transmit(channela, channelb, v) endThis won't work, as you're storing the result of modem.transmit in per[k], not an actual function.
for k, v in pairs(msg[4]) do
per[k] = function(...)
modem.transmit(channela, channelb, {call = v,params = {...}})
return {os.pullEvent("modem_message")}[5]
end
end
Obviously you'd want some timeout, connection confirm and id confirmation on this stuff aswell, but you get the idea. It needs to be a function
Posted 06 May 2014 - 10:52 PM
CometWolf, on 06 May 2014 - 09:57 PM, said:
for k, v in pairs(msg[4]) do per[k] = modem.transmit(channela, channelb, v) endThis won't work, as you're storing the result of modem.transmit in per[k], not an actual function.
for k, v in pairs(msg[4]) do
per[k] = function(...)
modem.transmit(channela, channelb, {call = v,params = {...}})
return {os.pullEvent("modem_message")}[5]
end
end
Obviously you'd want some timeout, connection confirm and id confirmation on this stuff aswell, but you get the idea. It needs to be a functionEdited by KingofGamesYami, 06 May 2014 - 10:54 PM.
Posted 06 May 2014 - 11:01 PM
Edited by HometownPotato, 06 May 2014 - 11:27 PM.
Posted 06 May 2014 - 11:13 PM
HometownPotato, on 06 May 2014 - 11:01 PM, said:
mon = wp.wrap("right", 10, 10)
mon.write("hello") --how do I get that this is calling the peripheral associated with "right" on the 10 frequency?
Edited by KingofGamesYami, 06 May 2014 - 11:18 PM.
Posted 06 May 2014 - 11:45 PM
Bomb Bloke, on 06 May 2014 - 11:40 PM, said:
per.side = side per.channela = channela per.channelb = channelb
per = {
command = function(self) --#do stuff
end
}
per:command()
but then, thats what I get from teaching myself by looking at other peoples code (Lyqyd's touchpoint api)function wrap(side, channela, channelb)
local per = {
side = side,
channela = channela,
channelb = channelb,
}
modem.open(channelb)
modem.transmit(channela, channelb, side)
msg = {os.pullEvent("modem_message")}
for k, v in pairs(msg[4]) do
per[k] = function(...)
modem.transmit(channela, channelb, {call = v, params = {...}})
return ({os.pullEvent("modem_message")})[4]
end
end
return per
end
Edited by KingofGamesYami, 06 May 2014 - 11:52 PM.
Posted 07 May 2014 - 12:06 AM
for k, v in pairs(msg[4]) do
per[k] = function(self, ...)
modem.transmit(self.channela, self.channelb, {call = self.side, params = {...}})
return ({os.pullEvent("modem_message")})[4]
end
end
Posted 07 May 2014 - 12:37 AM
Bomb Bloke, on 07 May 2014 - 12:06 AM, said:
for k, v in pairs(msg[4]) do
per[k] = function(self, ...)
modem.transmit(self.channela, self.channelb, {call = self.side, params = {...}})
return ({os.pullEvent("modem_message")})[4]
end
end
setmetatable(per, {__index = msg[4]})
something like this?Edited by KingofGamesYami, 07 May 2014 - 12:43 AM.
Posted 07 May 2014 - 01:04 AM
Edited by KingofGamesYami, 07 May 2014 - 01:06 AM.
Posted 07 May 2014 - 01:25 AM
Posted 07 May 2014 - 01:37 AM
Bomb Bloke, on 07 May 2014 - 01:25 AM, said:
oldos = {}
for k, v in pairs(os) do
oldos[k] = v
end
function os.pullEvent()
event = {oldos.pullEvent()}
if event[1] == "modem_message" and event[5][1] == "wpe" then
return unpack(event[5][2])
else
return unpack(event)
end
end
Edited by KingofGamesYami, 07 May 2014 - 01:37 AM.
Posted 07 May 2014 - 02:49 AM
Posted 07 May 2014 - 11:51 AM
Bomb Bloke, on 07 May 2014 - 02:49 AM, said:
oldos = {}
for k, v in pairs(os) do
oldos[k] = v
end
function os.pullEvent(...)
local args = {...}
if args[1] == "wpe" then
event = oldos.pullEvent("modem_message")
if type(event[5]) == "table" and event[5][1] == "wpe" then
return unpack(event[5][2])
else
return os.pullEvent(unpack(args))
end
else
local event = {oldos.pullEvent(unpack(args))}
end
if event[1] == "modem_message" and type(event[5]) == "table" and event[5][1] == "wpe" and (#args == 0 or (#args = 1 and args[1] = "wpe")) then
return unpack(event[5][2])
else
return unpack(event)
end
end
Edited by KingofGamesYami, 07 May 2014 - 12:01 PM.
Posted 07 May 2014 - 12:03 PM
Posted 07 May 2014 - 12:10 PM
return os.pullEventRaw(unpack(args))will this turn os.pullEvent() into an os.pullEventRaw(), thus unintentionally making peoples scripts un-terminatable?
Posted 07 May 2014 - 12:16 PM
Posted 07 May 2014 - 12:27 PM
Bomb Bloke, on 07 May 2014 - 12:16 PM, said:
Posted 07 May 2014 - 09:57 PM
Edited by KingofGamesYami, 07 May 2014 - 10:09 PM.
Posted 07 May 2014 - 10:24 PM
0 members, 1 guests, 0 anonymous users