Web script loading system

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Web script loading system.
Older Method

If you want to store the file locally use the Older Method

What does it do?
All it does is load a script from a website (pastebin, github or something) and caches it into a local folder.
 
What do you need?Instructions

  • Create a folder named "Web" in the directory of your project
  • Paste that into your project.
  • Create a new script section.
  • Write or copy your script inside of your file hosting site (github, etc) for this example I will just enable a switch.
  • This is how the file should look in github (for this example)
  • Okay in your script window write your GET request: for my example it should look like this:
begin http_reply = HTTP::get('', 'raw.githubusercontent.com','/Heark/rgss3/master/switch.rb')replace raw.githubusercontent.com with what ever site you are using, if it was pastebin it should be:

begin http_reply = HTTP::get('', 'pastebin.com','/raw.php?i=msA8g6bV')In our script window we should have this so far:

begin http_reply = HTTP::get('', 'raw.githubusercontent.com','/Heark/rgss3/master/switch.rb')If you do not have this, turn back now.
 
Next, we create the 'out.rb' file:
add this simple line:

out_file = File.new("Web/out.rb", "w")next we want to write our webcalled script to 'out.rb';
 
add this simple line:

out_file.puts(http_reply)next add this

rescue IOError => e#...ensureout_file.closeendFixes an error that occurs.
next add:
 

if File.exist?('Web/out.rb')File.delete('Web/out.rb')endWe add this because if the the file is already in our folder we want to delete it so it can pull the newest version.
 
So our Script Window should look like this:

if File.exist?('Web/out.rb')  File.delete('Web/out.rb')endbegin  http_reply =  HTTP::get('',  'raw.githubusercontent.com','/Heark/rgss3/master/switch.rb')out_file = File.new("Web/out.rb", "w")#...out_file.write(http_reply)rescue IOError => e#...ensureout_file.closeendYou could add many scripts just change the name of out.rb to whatever you want
 
Finally call the script in game or in the script window using the script call:

load_script("Web/out.rb")
  • First get Dekita's basic HTTP processing script.
  • Get all necessary files (DLLS and what not).
Write this in your script window:

def load() return eval HTTP::get('', 'raw.githubusercontent.com', '/Heark/rgss3/master/switch.rb')endThen use the call:

load()Terms of Use:
For non-commercial use only, Dekyde Studios forbids use in commercial projects
Hime requests that you speak to him.
 
Credits
Jet
Tsukihime
Dekyde Studios / Dekita
Yuuta Kirishima
Credit the above people.
 
Last edited by a moderator:

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
Very nice!

It's usefull for people who want to do some kind of "update system", like I did on my game. This way, if you fix something in a script on your game, the players won't have to redownload the whole Game.rgss3a file.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Yes! :) I formed it because I wanted to create a Mystery Gift(If you've played pokemon you know what this is) like system in which an event only appears during special Events Like on Christmas the player can talk to certain NPC to give you a gift.
 

Jet

Flying in a sky near you
Veteran
Joined
Mar 19, 2012
Messages
172
Reaction score
103
First Language
English
Primarily Uses
If you're using it only to load a script from the web, and not caching the script/checking for latest versions. Basically, if you're trying to do the exact thing listed in the topic, it can be shortened down to

Code:
eval HTTP::get('', 'raw.githubusercontent.com', '/Heark/rgss3/master/switch.rb')
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Yes but this caches the file so it can be called for later use.


It stores the data it gets from github into a local rb file.


Sorry for not being to clear in the topic.
 
Last edited by a moderator:

Jet

Flying in a sky near you
Veteran
Joined
Mar 19, 2012
Messages
172
Reaction score
103
First Language
English
Primarily Uses
Right but, your code right now would re-download the file every time at boot, so saving it as a file seems pointless. It might even be better to just hold it in memory if it's a script that will be called more than once per boot.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
def load() return eval HTTP::get('', 'raw.githubusercontent.com', '/Heark/rgss3/master/switch.rb')endIf I don't want to cache it I could just call this, but the file wouldn't be stored locally and I won't be able to change it in-game.

You are right, if you store it locally you won't be able to encrypt your game, I'll update the topic.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top