Rougeminner
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
New Event
Started by Rougeminner, 30 November 2014 - 12:30 AMPosted 30 November 2014 - 01:30 AM
I don't know if this is possible without adding another mod to the game. but is there a way to create my own redness event without making my own mod
Rougeminner
Rougeminner
Posted 30 November 2014 - 01:36 AM
Yes, the short answer boils down to "use os.queueEvent()" (which happens to be how the rednet API itself does it).
Posted 30 November 2014 - 02:36 AM
ok thank you bomb bloke i thought this was what people use but the example i saw didn't make sense to me
i want this event to have 5 arguments and be call rednet_ping. the args in queevnet make it sound like it triggers an event can you please post demonstration code
i want this event to have 5 arguments and be call rednet_ping. the args in queevnet make it sound like it triggers an event can you please post demonstration code
Posted 30 November 2014 - 02:57 AM
Well, yes, os.queueEvent() certainly does trigger events. That's what you want to do, isn't it? If not, what DO you want to do? Perhaps post some pseudo-code to try and get your point across?
I could certainly post another example, but not without re-iterating what the examples on the linked wiki page demonstrate. I suggest opening up the ComputerCraft archive and hunting down the rednet API file.
I could certainly post another example, but not without re-iterating what the examples on the linked wiki page demonstrate. I suggest opening up the ComputerCraft archive and hunting down the rednet API file.
Posted 30 November 2014 - 03:15 AM
i want to make another rednet event called redenet_ping to check this event u would do
event,arg1,arg2,arg3,arg4,arg5 = os.pullEvent(Raw)()
from this point arg1 is sender ID
arg2 is protocol
arg3 is timer
arg4 is packet
arg5 is timeout
event,arg1,arg2,arg3,arg4,arg5 = os.pullEvent(Raw)()
from this point arg1 is sender ID
arg2 is protocol
arg3 is timer
arg4 is packet
arg5 is timeout
Posted 30 November 2014 - 03:21 AM
as the example shows on the os.queueEvent page you would do the following
would be received like so
though I'm not sure what the point of the 'timeout' arg is…
os.queueEvent( "rednet_ping", 5, "protocol", 0.5, {type = "ping"}, 200 )
would be received like so
local event, id, protocol, timer, packet, timeout = os.pullEvent()
though I'm not sure what the point of the 'timeout' arg is…
Edited on 30 November 2014 - 02:21 AM
Posted 30 November 2014 - 03:43 AM
typo didn't mean timeout still thinking about that one should be. any ideas
Posted 30 November 2014 - 03:49 AM
how will this permanently add it to the list of computercraft events rednet ping does not exist yet
Edited on 30 November 2014 - 02:49 AM
Posted 30 November 2014 - 03:49 AM
you don't need to have 5, you could have one if you wanted
os.queueEvent( "rednet_ping", 5 )
local event, senderId = os.pullEvent()
Posted 30 November 2014 - 04:04 AM
i want this to be fired on rednet.recive() or rednet_message with out writing queue event in the script
i want to send it like this rednet.ping(0, 'ping', os.startTimer(), "ping", [ ])
i am working on the rednet ping part so how do i make it fire rednet ping when it receives rednet.ping()
i want to send it like this rednet.ping(0, 'ping', os.startTimer(), "ping", [ ])
i am working on the rednet ping part so how do i make it fire rednet ping when it receives rednet.ping()
Posted 30 November 2014 - 04:06 AM
I think you need to take a step back for a little bit do as Bomb Bloke suggested and have a read of the Rednet API to see how it functions, hopefully that will give you a better understanding of how you should approach this problem.
Posted 30 November 2014 - 04:10 AM
i know i am no expert and by now your probably pulling your hair out with me and i am sorry. i will look into rednet api
Posted 30 November 2014 - 04:58 AM
can you display the code for you bitnet tower event from moarperipherals please thats all i need i will be able to do the rest
Posted 30 November 2014 - 06:25 AM
it is a mod, I do it Java-side, with the Java version of os.queueEvent.
Edited on 30 November 2014 - 05:25 AM
Posted 30 November 2014 - 07:23 AM
Summarising the rednet API:
When a computer boots, it runs bios.lua, and that starts the shell (CraftOS). But it also runs another function in parallel with the shell - rednet.run(), which constantly checks for modem events and then queues "rednet" events if suitable (not all modem traffic is intended to represent rednet traffic).
I suspect that whatever your overall goals are, you're probably better off creating some wrapper functions that make use of the existing rednet API functions, rather than trying to replace rednet altogether. For example, take a look at rednet.host() and rednet.lookup() - it's pretty easy to rig up a rudimentary "ping" system out of those.
When a computer boots, it runs bios.lua, and that starts the shell (CraftOS). But it also runs another function in parallel with the shell - rednet.run(), which constantly checks for modem events and then queues "rednet" events if suitable (not all modem traffic is intended to represent rednet traffic).
I suspect that whatever your overall goals are, you're probably better off creating some wrapper functions that make use of the existing rednet API functions, rather than trying to replace rednet altogether. For example, take a look at rednet.host() and rednet.lookup() - it's pretty easy to rig up a rudimentary "ping" system out of those.
Posted 30 November 2014 - 08:26 PM
well yes. i didn't use rednet.lookup() but my code works. i was just expeirmenting with events seeing if i could create one it didn't need to be rednet_ping i just thought about it and decided it was kinda simple code.
guess not
guess not
Edited on 30 November 2014 - 07:26 PM