Click here to join us on IRC (#charas on irc.freenode.net)!
var n; //temporarily declaring the n variable, which is what I normally use for temporary thingsn=instance_create(x,y,O_follower);/*here's where the cool stuff happens.When you create an object, it returns its id, which is unique to ever instance. You can then set the object that you just created's variables afterwards, kind of like this:*/n.follow=self.id//you need the self.id part, so that the instance follows the object you just created.motion_set(random(360),2)//just so the other instance follows.
//This is going to be primitive, because I don't want to write an entire system for following something right now.action_potential_step(follow.x,follow.y,1,0)/*this is an action command.It's equivalent is the 'Step Avoiding' tile in the Move tab in item properties.Also, sorry if it doesn't work, because I've never actually used it.*/
//Remember to set up the variables in the create event, alright?if timergo=1 then timer+=1//timergo is just a variable that'll go false when the timer reaches whatever.if timer=90{ //whatever code you need timergo=0//this isn't needed, neither is the variable itself, you can make the timer recursive, so it'll go on forever. timer=0//this resets the timer, it is needed.}
n="This is a string. Note the commas."
n="instance_create(self.object_index)
execute_string(n)
//Yeah, I know, this is ridiculously easy code to pull off, but it can be pretty cool.depth=-y
switch(variable here)//I most often use them for keyboard_check stuff{ case condition: /*the colon is needed, and in the keyboard_check example, you can do stuff likeord('1') or vk_up...stuff like that*/ action; //self explanatory break; //to make sure your code doesn't loop forever, this can be removed but I personally don't do that //repeat as necessary}
if !variable_global_exists("BGMp") variable_global_set("BGMp",0)//in case the variable doesn't exist, so you can just copy/paste this into your game :Pif !variable_global_exists("BGM") variable_global_set("BGM",/*default music*/)//same hereif !sound_isplaying(global.BGM){ sound_stop(global.BGMp) sound_loop(global.BGM) global.BGMp=global.BGM}
Ellie: I had a slice of ham in my hand. I was going to drop it, so I slapped it hard. It attached itself to the wall
You can also use execute_file(), and write a file (if you're using a text file, use the full name, as in code.txt), but I personally don't recommend this due to the ease of people rewriting it.
if global.p1character = 'Ed' {Ed_health -= 20}if global.p1character = 'Fruckert' {Fruckert_health -= 20}if global.p1character = 'Charas' {Charas_health -= 20}etc...
execute_string( string(global.p1character) + '_health -= 20')
...and I might as well mention the ever-useful for and while loops.