de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Script repository
PostPosted: Fri Jul 31, 2020 5:26 am 
Offline
Addict
User avatar
Hey all,

I'm a total newbie to writing scripts but with all the great scripts being written now, I'd love to contribute as a way to show thanks. The tough part is that it has been a really long time since I've done any real coding.

As I've been trying to learn the ropes, I've caught myself repeatedly searching other scripts for methods (or functions) I could use or modify. This is when I had a thought. How about we create a repository of script functions that we share to aid in creating other scripts? For example, one used frequently for newer scripts is for configuring an estim. But there is room for tons more.

For example, rolling a dice, determining sex or taking a picture. It seems redundant to have each user try to work out the bugs themselves.

Thoughts?

_________________
Just here for laughs ... and grimaces. ;)


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Fri Jul 31, 2020 2:21 pm 
Offline
Addict
That's a good idea! :geek:
Something like the tutorial from Banjo, but with bigger functions. (Functions are named closures in groovy, right?)

I wanted to do something like this, because I see lot's of unreadable code. My (personal, hehe ;)) teacher for informatics always say: Write readable code! (Or you get spanked! :lol:)

Let me start with rolling a dice:

Code:
// Dice Roll Example
// by MissEshock2002

// This script, from https://ss.deviatenow.com, is protected by this licence:
// CC0

setInfos(9, "Dice Roll Example", "Dice Roll Example for 1 or more Dice",
        "MissEshock2002",
        "v1.0", 0x222222, "en", ["example", "tutorial"]);


def getDiceRoll = { numberOfDice = 1 -> // default 1 dice, if no value given
    // returns the sum of numberOfDice rolled dice

    int rollSum = 0 // sum of all rolled dice

    // loop: repeats numberOfDice times
    (1..numberOfDice).each {
        // getRandom(6): random between 0 and 5; +1 to get 1 to 6
        // roll += ... sums up all rolls
        rollSum += getRandom(6) + 1
    }

    return rollSum
}


int numberOfDice = 1

boolean endLoop = false
while (!endLoop) { // loop repeats till endLoop = true

    // while loop to make sure input is positive number
    // repeat, if input is wrong
    while (true) {
        numberOfDice = getInteger("How many dice to roll?", numberOfDice)
        if (numberOfDice > 0) break // if input is correct: end while loop with break
    }

    int roll = getDiceRoll(numberOfDice)

    // same as if ... else ...: (condition) ? "condition is true" : "condition is false"
    String diceWord = (numberOfDice == 1) ? "Die" : "Dice"

    // show results:
    show("You rolled " + roll + " with " + numberOfDice + " " + diceWord + ".")
    // show(String.format("You rolled %s with %s %s.", roll, numberOfDice, diceWord)) // the same with formatted string

    showButton("->")

    if (!getBoolean("Repeat?")) endLoop = true
}

show("- End of Script -")


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Fri Jul 31, 2020 3:45 pm 
Offline
Addict
User avatar
Thank you for the quick reply and contribution!! :D :D :D

Hopefully I'll be able to contribute some soon. l'm still trying to get all my syntax and such figured out to make something workable. :oops:

_________________
Just here for laughs ... and grimaces. ;)


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Sun Aug 02, 2020 11:11 am 
Offline
Addict
My examples for the Script repository -> https://pastebin.com/u/MissEshock2002

New is a function for something many scripts have: Instructions
(I made the code with CC0. This means you can make what you want with it.)


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Mon Aug 03, 2020 2:43 pm 
Offline
Addict
User avatar
Another great contribution. Thank you, MissEshock2002.

I skimmed your instructions code and that will be very helpful!

_________________
Just here for laughs ... and grimaces. ;)


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Thu Aug 06, 2020 7:20 pm 
Offline
Addict
I had put a important thing to the examples: load lists.
The list can only have one type of data. List in list does not work with the functions!

My examples for the Script repository -> https://pastebin.com/u/MissEshock2002


Top
 Profile Send private message 
 
 Re: Script repository
PostPosted: Mon Aug 10, 2020 12:15 am 
Offline
Addict
Please write what you want to see as more used often things?

(I can let my inner teacher out. :lol:)


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2015
This website uses session cookies only.