CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Ren'Py Execute a loop in the Renpy console

DancingPriest

Newbie
Sep 29, 2017
58
111
Hello world.

I apologize if this is the wrong forum for my question.

Is it possible to run a loop in the console of renpy? If so, what are the limiting parameters; specifically, can conditional statements be used?

This is the basics of what I'm trying to accomplish (obviously not python, just showing what I want to accomplish):
Code:
for (int i = 0; i < NPC.size(); i++) {
    if (NPC[i].love != 100 && NPC[i] != uniqueCharacter)
        NPC[i].love = 100;
        NPC[i].suggestibility = 100;
        NPC[i].obedience = 300;
        NPC[i].happiness = 300;
        NPC[i].arousal = 100;
}
The specific situation is with Lab Rats 2 - Reformulate. The mod authors post all the files on their github, so I'm able to poke around for variable names and game logic. Essentially, I want to write a loop that will iterate over all the non-special NPC's, and 'top-up' everyone's stats (game has stat decay). Preferably, in a way that is easily repeatable, as I don't want to go to the cheat screen of 95 NPC's and adjust stats individually. I just can't figure out how to make a loop run in the console.

I have tried using "list comprehension"?; however, I may not be understanding it correctly, as multiple lines give a syntax error, and I can't figure out a python single line looping conditional.

The renpy documentation ( ) says that scripts can be run? Is that something that I need to write in LUA to run? Basically, would it be possible to write my code into a file, put it in the game directory, and run it as many times as needed from the console?

// EDIT

Well, I figured out how to do multiple line entries in the console. It was expecting an end of line character ":". When a line ends in ":" the console allows you to enter a line and hit enter to get to the next line. Hitting enter twice exits the line input and runs the code. This is rather messy, having to copy/paste individual lines. If anyone knows how to write a python/renpy script and run it from the console, I would greatly appreciate it.

Here is the sample code I got to work
Python:
a=0
b=0
d=0
while a < 10:
    b=0
    while b < 10:
        b += 1
        d += 1
    a +=1
At the end, a=10, b=10, d=100; so, this is performing as expected. Just messy to input. And easy to break. "c" is a variable in use, so that caused problems, and infinite loops just crash the game.

Here is the code my sleep deprived brain came up with.

Python:
a = 0
b = 0
peopleCount = 0
while a < len(list_of_jobs):
    b = 0
    while b < len(people_with_job(list_of_jobs[a])):
        if people_with_job(list_of_jobs[a])[b].name == 'Gabrielle': // add all special NPC
            peopleCount += 1
        else:
            people_with_job(list_of_jobs[a])[b].love = 100
            people_with_job(list_of_jobs[a])[b].suggestibility = 100
            people_with_job(list_of_jobs[a])[b].obedience = 300
            people_with_job(list_of_jobs[a])[b].happiness = 300
            people_with_job(list_of_jobs[a])[b].arousal = 100
            peopleCount += 1
        b += 1
    a += 1
It worked on 80 of the 94. It didn't work on prostitutes and jobless. I need to fix the code, but I can do that later.

If anyone has any useful tips, I would love to learn.
 

Mike145

Newbie
Jul 14, 2018
90
270
If you've already looked at the code, wouldn't it be easier to find where stat decay happens (I would assume it happens every day) and either remove it completely or run your loop at the start of each day?

You probs know by how much the stats decay, so it shouldnt be hard to find the section of the code you want.
 

tooldev

Active Member
Feb 9, 2018
719
659
If you've already looked at the code, wouldn't it be easier to find where stat decay happens (I would assume it happens every day) and either remove it completely or run your loop at the start of each day?

You probs know by how much the stats decay, so it shouldnt be hard to find the section of the code you want.
Exactly my thought as well. Since the decay runs across the board, disabling it should solve the problem in general. Add a 'maxed stats' at creation of chars and that should do the trick.
 
  • Like
Reactions: DancingPriest

DancingPriest

Newbie
Sep 29, 2017
58
111
If you've already looked at the code, wouldn't it be easier to find where stat decay happens (I would assume it happens every day) and either remove it completely or run your loop at the start of each day?

You probs know by how much the stats decay, so it shouldnt be hard to find the section of the code you want.
Exactly my thought as well. Since the decay runs across the board, disabling it should solve the problem in general. Add a 'maxed stats' at creation of chars and that should do the trick.
That actually makes a lot of sense. Thanks for the info.
 
  • Like
Reactions: tooldev