Jump to content


Dave-ee Jones

Member Since 19 Jan 2013
Online Last Active Today, 04:08 AM
-----

Topics I've Started

load() multiple functions in a string?

22 September 2017 - 03:48 AM

Hoi,

So, I'm trying to load multiple functions in a string, passing them to load(), but whenever I pass them the load() doesn't do ANYTHING. I don't know why..
The string looks like this:
local testString = [[os.queueEvent('char','t')
os.queueEvent('char','e')
os.queueEvent('char','s')
os.queueEvent('char','t')]]

I've tried the other way of doing it..
local testString = "os.queueEvent('char','t'); os.queueEvent('char','e'); os.queueEvent('char','s'); os.queueEvent('char','t')"

Just for clarification, the function is being sent over rednet to another computer which listens with this bit of code:
while true do
  local event,id,msg = os.pullEvent()
  if event == "rednet_message" then
	load(msg)()
  end
end

It does work if I just do one function in the string (e.g. 'os.queueEvent('char','t')'), but whenever I add more it doesn't like it.
I know I could pass a function over rednet and call it over the other side but I want to get this working, because it should be and since it's not I needa fix it!

[Trick] Event spoofing

18 September 2017 - 02:31 AM

Part 1 - Using the 'char' and 'key' events in an event queue
Spoiler

Part 2 - Adding different events
Spoiler

Disadvantages of using the event queue to call programs:
  • Queuing a program that uses "os.pullEvent()" will steal the next event in the event queue. So if, for example, you use a program that calls "os.pullEvent()" once, and you've told this program to run the event-pulling program and then "time" after it, it may only enter something like this:
    ime
    
    Where the event-pulling program steals the "char" event that has the argument "t". Keep in mind if you call a program that has a while-loop with "os.pullEvent()", it will keep stealing your events in the event queue until the program finishes. Not cool, I know. What is cool about it is you can pass events to that program - so if you know it's going to loop with "os.pullEvent()" you can queue specific events (e.g. mouse clicks for UIs, key presses etc. to navigate through a menu without you having to do anything), so it's cool in that sense.
  • Queuing a program that uses "sleep()" will completely wipe the event queue. This is because "sleep()" wipes the event queue. Pretty annoying, I know.

[GUI] Budj - GUI API

15 September 2017 - 02:42 AM

Budj
Dave-ee's GUI API!

Look! Another GUI API!
Yep. As a not-so-wise-man once said: "anudder one". It's not quite as good as something like Touchpoint, but it's got some different features that might be useful to some.

I despise having to use someone else's GUI APIs, as I always prefer to write my own APIs. It's more interesting, better for the learning experience, and better for your own applications. So, I made Budj. Budj is a top-notch bloke. He can do all kinds of things.

He can have multiple whiteboards for you to slap buttons and checkboxes on, he can draw and undraw objects, he can swap whiteboards when he wants to change whats on the screen. He can do all kinds of cool things.He can even assign functions to objects, handle your events for you and re-align or re-assign labels.

Usage:
Spoiler


Functions:
Spoiler



Demo program:
The demo program is pretty cool. Let me explain what it does.
When you click the button, it toggles the checkbox's 'DRAWN' variable. While it's undrawn you cannot interact with it.
When you click the button again, it toggles the checkbox to be drawn again.

When you toggle the checkbox it changes the button's label. You can actually swap the functions between the two objects, or even create more. I built the demo so it was very versatile and shows you what you can do.






Demo program's pastebin:

pastebin get Kte8gY84 demo



API's pastebin:

pastebin get ugKWxVGj budj



PLEASE give suggestions and feedback!


Loading an API - the best way?

12 September 2017 - 11:50 PM

Hoi,

I'm creating an API (GUI-based) and I'm wondering how best to load it as an API. It uses OOP (metatables and object-based function calling). Because of this, 'os.loadAPI' isn't working.

I'm currently using 'dofile(apiPath)', which is working well, but it also means all the metatables and their functions need to be global which means once the API gets bigger it might start taxing on the RAM and speed of the program.

Could someone point me in the right direction of how it could be done better, making it overall faster? Or is the way I'm doing it fine and I'm just being skeptical?

[Beta] Dodj - Dodgeball in CC!

04 September 2017 - 06:52 AM

Dodj
Dave-ee's Dodgeball for CC!

Look! It's dodgeball!
Yes it is! And it's completely working in every way (once you get catching-the-ball down pat).

The game has support for an unlimited amount of players natively. You can add more players by adding entries into the player settings table at the top of the program.

The ball changes colour based on what team threw it, so you can know whether to dodge it or try and catch it to throw it again. The ball also gets thrown in the direction you last moved, so you can do some fancy throw-it-against-the-back-wall shot. However it still bounces 1:1 in the direction it came from so no corner shots or anything like that, sadly. Might make an 8-direction play-style sometime.

The ball's speed can be adjusted in the settings at the top, just increase the frames per second.
You can change a player's team by changing the colour of a player in the player settings.

Usage:
dodj help -- displays the help text
dodj <players> -- choose the amount of players (need to setup controls for players 3 and up)


Controls:
PLAYER 1 (default):
W, A, S and D to move around, Left Shift to pickup/throw the ball, Z to stop moving when pressing a key (change direction instead of moving in a direction).

PLAYER 2 (default):
Arrow keys to move around, O to pickup/throw the ball (or catch it..) and P to stop moving.

Things you need to know if you want to be better at this game:
  • You can only catch the ball if you are facing where the ball is coming from.
  • Don't hold the action button after you have caught the ball, otherwise when you release it it will instantly throw the ball. Just press it right before the ball reaches you.
Changelog:
Spoiler


Pastebin:

pastebin get zsijDWCe dodj



PLEASE give suggestions and feedback! :D


I wish I had thought of this earlier for CCJam, would have been a pretty good entry as I haven't seen any other games like this yet. Might do in the near future, haha!