Registrarse

[pokeruby] Ver valores como texto, útil para DEBUGG

Jason

PkPower déjame poner tildes en mi nick ¬¬
Hola, lo compartí en el canal de disassembly del servidor pero dado que vi cierto interés lo comento por acá.

Es necesario el tutorial de @Inmortal Kaktus sobre cómo crear nuevos comandos, para la parte de investigación.

1. Necesitamos algún punto de referencia, ¿en qué parte de la aventura esto sucede? Bueno, en el de los sacos de hollín cuando nos dice la cantidad que nos falta lo hace. Busquemos esto.

Código:
Route113_GlassWorkshop_EventScript_163818:: @ 8163818
	setvar VAR_SPECIAL_A, 250
	subvar VAR_SPECIAL_A, 16456
	[B]buffernumberstring[/B] 0, 32778
	msgbox Route113_GlassWorkshop_Text_19E697, 4
	release
	end

2. Nos vamos directamente a include/macros/event.inc y usando nuestro súper poder "Ctrl + F", nos encontramos con esto:

Código:
	@ Converts the value of input to a decimal string, and writes that string to the specified buffer.
	.macro buffernumberstring out, input
	.byte 0x83
	.byte \out
	.2byte \input
	.endm
Ya nos podemos ir haciendo una idea de cómo se usa, no?
Código:
 buffernumberstring out, var
3. Vamos al msgbox del paso 1
Código:
Route113_GlassWorkshop_Text_19E697:: @ 819E697
	.string "Hmmm...\n"
	.string "There’s not enough ash here, huff-puff.\l"
	.string "I can’t make glass with this, huff-puff.\p"
	.string "Let’s see... {STR_VAR_1} is the number of steps\n"
	.string "you’ll need to walk for me to make you\l"
	.string "a BLUE FLUTE, huff-puff.$"
STR_VAR_1... no está con las demás variables.
(Las variables están todas definidas en include/constants/vars.h)

Código:
bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx)
{
	u8 stringVarIndex = ScriptReadByte(ctx);	
	u16 v1 = VarGet(ScriptReadHalfword(ctx));
    	u8 v2 = sub_80BF0B8(v1);

    	ConvertIntToDecimalStringN(sScriptStringVars[stringVarIndex], v1, 0, v2);
    	return FALSE;
}

En resumen: usamos el comando "buffernumberstring" para almacenar el valor numérico de una variable definida en include/constants/vars.h en una variable de texto STR_VAR_(N), donde N es
Código:
N = out + 1
Un ejemplo de uso:

Código:
MapaMuyChulo_EventScript_NombreGuay::
	buffernumberstring 0, VAR_REPEL_STEP_COUNT
	msgbox TextoCool, 2
	end
Código:
TextoChulo::
	.string "Te quedan {STR_VAR_1}.$"
Les dejo a ustedes el insertarlo ;D
 
Arriba