[RM2K3] REQUEST: PLUGIN TO TOGGLE SWITCH WITH SLASH COMMAND IN MESSAGES

Posts

Pages: 1
Hello. I'm in need of a DynRPG plugin that will allow me to toggle the on/off status of a switch using a slash command in Show Message commands. I don't imagine that this should be too difficult to make, but I don't know how to write a plugin, or I'd do it myself. The way I imagine it working is to use "/f(xxxx)", where xxxx is equal to a switch number. So if I had "/f(237)" in a Show Message dialogue, it would turn switch 237 on if it was off, and off if it was on when the message being printed onscreen reaches that point where the slash command is (and, of course, it would not actually print the slash command itself onscreen, lol). I hope someone can help me out with this; I would really appreciate it. Credit will be duely given, of course.

EDIT NOTE: The "(x)" and "(237)" above were intended to have square brackets, but they weren't showing, so I had to edit them to parentheses instead.

EDIT, DEC 5 2017: Been two weeks, and I'm still looking for someone to write this plugin. It'll save me a ton of otherwise needless effort, so I really need this. It's also okay if, instead of using /f(xxxx) to toggle the status of a switch, it could be /f(xxxx) to turn a switch specifically off, and have /F(xxxx) to turn a switch specifically on. If that would be easier, then that's fine too. Please, help me, RMN, you're my only hope. <3
And, of course, whoever writes it can have an early look at the game, if they're interested.
MessageExtender2 does stuff like this.

https://rpgmaker.net/engines/rt2k3/utilities/95/

You will have to alter the code a bit, to turn switches on and off.

https://rpgmaker.net/engines/rt2k3/utilities/17/

This helps as a tutorial for turning switches on and off, among other things. You want to find the code that says...

RPG::switches[parsedData->parameters[2].number] = true;


True is ON, False is OFF. I believe you would switch parsedData->parameters to the variable entered as part of the thing.

Also it's \ not / .
Unfortunately, this is not particularly helpful to me. You say "among other things". What are the other things? I've tried asking my friend who does know C++ if he can make sense of your post, but he hasn't gotten back to me yet, and it's been twenty days now since I asked him about it.

Without telling me *exactly* what I have to change and *exactly* what I have to change it *to*, I'm still lost. Furthermore, several months ago, I had my abovementioned friend try to alter this exact plugin, and despite trying many, many, many different things, we never had any success. Unfortunately, however, my C++literate friend is not at all familiar with RPG Maker. So I need someone who is familiar with both who knows exactly what adjustments need to be made.

It has now been four months since I started this thread, and I *still* need this (theoretically) simple adjustment. I'm *sure* that there are many people on this forum who could help, and it would surely only take a few minutes of your time. I'm literally begging at this point, please, someone help me with this.
Holdup, I'll go display the code, for convenience.

//created by Kazesui and bulmabriefs144

#include <DynRPG/DynRPG.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

[color=blue]These are called includes, they allow the code below to run. I have more of these than I likely need[/color]

std::map<std::string, std::string> configuration;
int DynArray[100][1000];
int DynPointer;
int DynMystery;

[color=blue]These are global variables. They are called global because they are introduced outside of the functions.[/color]

bool onStartup(char *pluginName) {
// We load the configuration from the DynRPG.ini file here
configuration = RPG::loadConfiguration(pluginName);
return true; // Don't forget to return true so that the start of the game will continue!
}


bool onComment( const char* text,
const RPG::ParsedCommentData* parsedData,
RPG::EventScriptLine* nextScriptLine,
RPG::EventScriptData* scriptData,
int eventId,
int pageId,
int lineId,
int* nextLineId )
{
std::string cmd = parsedData->command;
std::string filecode;



if(!cmd.compare("store_string"))
{
RPG::actors[parsedData->parameters[0].number]->name = parsedData->parameters[1].text;
return false;
}
//Moved file stuff to file_control
if(!cmd.compare("store_item"))
{
RPG::actors[parsedData->parameters[0].number]->name = RPG::getItemName(parsedData->parameters[1].number);
return false;
}
if(!cmd.compare("store_condition"))
{
RPG::actors[parsedData->parameters[0].number]->name = RPG::getConditionName(parsedData->parameters[1].number);
return false;
}
if(!cmd.compare("store_skill")) //new code
{
RPG::actors[parsedData->parameters[0].number]->name = RPG::getSkillName(parsedData->parameters[1].number);
return false;
}

if(!cmd.compare("store_mystery")) //sets a specific variable to an artificial variable
{
DynMystery = parsedData->parameters[0].number;
return false;
}
if(!cmd.compare("random_mystery")) //sets a specific variable to a
{
int MinNum = parsedData->parameters[0].number;
int MaxNum = parsedData->parameters[1].number;
DynMystery = rand()%(MaxNum+1)+MinNum; // creates a random range
return false;
}
if(!cmd.compare("store_variable")) //sets a specific variable to an artificial variable
{
DynMystery = RPG::variables[parsedData->parameters[0].number];
return false;
}
if(!cmd.compare("store_switch")) //sets a specific variable to 0 or 1
{
DynMystery = RPG::switches[parsedData->parameters[0].number];
//doesn't pass if failed
return false;
}

if(!cmd.compare("get_variable")) //sets a specific variable to a
{
DynPointer = parsedData->parameters[0].number;
RPG::variables[DynPointer] = DynMystery; //variable isn't set, it's previously stored

return false;
}

if(!cmd.compare("get_switch"))
{
int BooleanVar;
DynPointer = parsedData->parameters[0].number;
BooleanVar = DynMystery;
if (BooleanVar == 0)
{
RPG::switches[DynPointer] = false;
}
if (BooleanVar == 1)
{
RPG::switches[DynPointer] = true;
}

return false;
}

if(!cmd.compare("mystery_array")) //new code
{
int x = parsedData->parameters[0].number;
int y = parsedData->parameters[1].number;
DynArray[x][y] = DynMystery;
// stores mystery into arayy
return false;
}

if(!cmd.compare("store_array")) //new code
{
int x = parsedData->parameters[0].number;
int y = parsedData->parameters[1].number;
DynArray[x][y] = parsedData->parameters[2].number;
// parsedData->parameters[].number didn't work
return false;
}

if(!cmd.compare("get_array")) //new code
{
int X = parsedData->parameters[0].number;
int Y = parsedData->parameters[1].number;
RPG::system->variables[parsedData->parameters[2].number] = DynArray[X][Y];
return false;
}

if(!cmd.compare("compare_array")) //new code
{
int TestArray, ArrayValue;
int X = parsedData->parameters[0].number;
int Y = parsedData->parameters[1].number;
TestArray = DynArray[X][Y];
ArrayValue = parsedData->parameters[2].number;
if (TestArray == ArrayValue)
RPG::switches[parsedData->parameters[3].number] = true;
else
RPG::switches[parsedData->parameters[3].number] = false;
// compares an array, and if it matches the number turn a switch ON
return false;
}
if(!cmd.compare("compare_text"))
{
std::string A = RPG::actors[parsedData->parameters[1].number]->getName();
std::string B = parsedData->parameters[2].text;
if(!A.compare(B))
RPG::switches[parsedData->parameters[0].number] = true;
else
RPG::switches[parsedData->parameters[0].number] = false;
return false;
}

if(!cmd.compare("compare"))
{
std::string A = RPG::actors[parsedData->parameters[0].number]->getName();
std::string B = RPG::actors[parsedData->parameters[1].number]->getName();
if(!A.compare(B))
RPG::switches[parsedData->parameters[2].number] = true;
else
RPG::switches[parsedData->parameters[2].number] = false;
return false;
}
return true;
}


And so on, if you have some understanding of math, you can figure it out.

I'll discuss each thing later, I think.

So basically, the include stuff is you libraries, you use that for specific codes. Below that is global variables. Below that is functions, which hold local variables and general code. http://rpg-maker.cherrytree.at/dynrpg/ Show the guy to this website.

Now, the onStart is a function for all rpgmaker events that happen when you start.
onComment means whenever you use the comment button and precede it with @ such as @store_string

I have a tutorial saying generally what each comment code does. Hold on...

--------------------------------------
KazString Storage Plugin
--------------------------------------

Stores text strings into a hero name of choice
This is done by writing specific "comment commands", using the
comment option in event editor.


commands:
-----------

@store_string
parameter#1 ID of hero
parameter#2 Text string
parameter#3 end

ex. @store_string 3, "hello world!", end
this command will store "hello world!" as the hero name of hero with ID = 3
Mind you that you must use double quotations (") around your text string!


@store_item
parameter#1 ID of hero
parameter#2 ID of item

Stores an item name into a hero name

@store_condition
parameter#1 ID of hero
parameter#2 ID of condition

Stores the condition name into a hero name

@store_skill
parameter#1 ID of hero
parameter#2 ID of condition

Stores the condition name into a hero name


@store_mystery
parameter#1 value
(stores into a variable named mystery)

@store_variable
parameter#1 variable
(stores variable information into mystery)

@store_switch
parameter#1 switch
(stores switch information into mystery)

@random_mystery
parameter#1 min range
parameter#2 max range
(random number storage. 0,1 gives a number between zero and 1)

@get_variable
parameter#1 variable
(stores mystery result into variable)

@get_switch
parameter#1 switch
(stores mystery result into switch, and turns it on or off)

@mystery_array
parameter#1 ID of array
parameter#2 Position of array (that is 2 , 3 is array 2 position 3)
(stores mystery in array, in place of parameter 3)


@store_array
parameter#1 ID of array
parameter#2 Position of array (that is 2 , 3 is array 2 position 3)
parameter#3 number/value

Stores the name info into an array. There are a maximum of about 20 arrays and 1000 positions, so you can use this to store a lot of data.

@get_array
parameter#1 ID of array
parameter#2 Position of array (that is 2 , 3 is array 2 position 3)
parameter#3 variable

Stores the array info into a variable. This is useful for rapidly replacing numbers or working with massive data.

@compare_array
parameter#1 ID of array
parameter#2 Position of array (that is 2 , 3 is array 2 position 3)
parameter#3 number
parameter#4 switch

Checks the value of an array. If it is the same, turn on a switch. This is useful for unique chests (get array can also be used).

@compare
parameter#1 ID of hero 1
parameter#2 ID of hero 2
parameter#3 switch



Checks if two hero names are the same. If yes, the designated switch will be set ON otherwise the switch will be set OFF

@compare_text
parameter#0 switch
parameter#1 ID of hero
parameter#2 string
parameter#3 end

Check hero name vs a string given. If yes, the designated switch will be set ON otherwise the switch will be set OFF. Be sure to add end at the end or things will screw up (strings are stupid)



So basically, if you want a message based thing, you just drag one of the codes here, into the MessageExtender thing.
Pages: 1