SexScripts : Script repository - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=985 Page 1 of 1

Script repository

bamaswitch [ Fri Jul 31, 2020 5:26 am ]

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?

Re: Script repository

MissEshock2002 [ Fri Jul 31, 2020 2:21 pm ]

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 -")

Re: Script repository

bamaswitch [ Fri Jul 31, 2020 3:45 pm ]

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:

Re: Script repository

MissEshock2002 [ Sun Aug 02, 2020 11:11 am ]

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.)

Re: Script repository

bamaswitch [ Mon Aug 03, 2020 2:43 pm ]

Another great contribution. Thank you, MissEshock2002.

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

Re: Script repository

MissEshock2002 [ Thu Aug 06, 2020 7:20 pm ]

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

Re: Script repository

MissEshock2002 [ Mon Aug 10, 2020 12:15 am ]

Please write what you want to see as more used often things?

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

Re: Script repository

MissEshock2002 [ Tue Aug 18, 2020 6:53 pm ]

I made a example for card games: https://pastebin.com/vGMCUznR
All functions and examples can be used to make most card games.

Re: Script repository

bamaswitch [ Wed Aug 19, 2020 3:44 pm ]

Thank you, MissEshock.

I haven't had much time to work on my beginner's lessons but your contributions are great places to learn from.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011