1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-04 13:52:21 +00:00
UltimateTrainingModpack/src/lib.rs

50 lines
1.1 KiB
Rust
Raw Normal View History

2020-04-08 00:21:52 -04:00
#![no_std]
#![feature(proc_macro_hygiene)]
2020-04-08 00:21:52 -04:00
2020-04-09 05:10:23 -04:00
use skyline::nn::account::{self, Uid, GetLastOpenedUser, GetNickname, Nickname};
2020-04-09 21:54:01 -04:00
use skyline::smash::hash40;
2020-04-09 21:54:01 -04:00
#[skyline::main(name = "module_name_test")]
2020-04-08 00:21:52 -04:00
pub fn main() {
2020-04-08 01:13:06 -04:00
println!("Hello from Skyline Rust Plugin!\n");
2020-04-08 00:21:52 -04:00
2020-04-08 01:13:06 -04:00
for i in 0..3 {
println!("{}", i);
2020-04-08 00:21:52 -04:00
}
2020-04-09 05:10:23 -04:00
let nickname = unsafe { get_last_user_nickname() };
println!("Last nickname: {}", nickname);
2020-04-09 21:54:01 -04:00
println!("Compile-time hash40 of 'accel_x': {:010X}", hash40("accel_x"));
let string = "accel_x";
println!("Runtime hash40 of '{}': {:010X}", string, hash40(string));
}
2020-04-09 05:10:23 -04:00
unsafe fn get_last_user_nickname() -> Nickname {
2020-04-09 21:54:01 -04:00
account::Initialize();
2020-04-09 05:10:23 -04:00
let uid = &mut Uid::new();
let mut nick = Nickname::new();
GetLastOpenedUser(uid);
GetNickname(&mut nick, uid);
nick
}
/*
use skyline::{
libc::{fopen, FileOpenMode, fwrite_slice, fclose},
c_str
};
fn write_to_file(file: &str, contents: &str) {
unsafe {
let file = fopen(c_str(file), FileOpenMode::Write);
fwrite_slice(contents.as_bytes(), file);
fclose(file);
2020-04-08 22:39:10 -04:00
}
2020-04-09 05:10:23 -04:00
}*/