Author Topic: Scritp Dont Work can anyone help me?  (Read 2026 times)

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Scritp Dont Work can anyone help me?
« on: January 18, 2014, 02:35:29 PM »
I made a new level where i have scritp press W,A,S,D Move the Block and script Dont Work. Can Help me?

Script:

function OnLoad()
  Game.SetKeyHook("W", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  Game.SetBlockPos("Block0", x, y -0.5 0)
end

function OnLoad()
  Game.SetKeyHook("A", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  Game.SetBlockPos("Block0", x, y -0 -0.5)
end

function OnLoad()
  Game.SetKeyHook("S", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  Game.SetBlockPos("Block0", x, y -0.5 -0)
end

function OnLoad()
  Game.SetKeyHook("D", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  Game.SetBlockPos("Block0", x, y -0 0.5)
end

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #1 on: January 18, 2014, 03:54:07 PM »
You can't use function OnLoad three times, you have to put it into one function OnLoad ;)
And you have to find different names, not always PutTheBlock ;P
« Last Edit: January 18, 2014, 03:56:48 PM by SeRe »

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #2 on: January 18, 2014, 03:57:53 PM »
But i try just whrite:

function OnLoad()
  Game.SetKeyHook("M", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  Game.SetBlockPos("Block0", x, y -2.5 -1)
end

And it dont work too.

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #3 on: January 18, 2014, 04:05:26 PM »
When I'm at my computer, I'll edit your scipt...
But btw you have to write "x,y = GetBlockPos("Block0")"

But before you post a topic at the forum, you should read the wiki first...
« Last Edit: January 18, 2014, 04:07:29 PM by SeRe »

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #4 on: January 18, 2014, 04:47:34 PM »
I Read Wiki... and i copy what is whrited there.

And:

function OnLoad()
  Game.SetKeyHook("M", "PutTheBlock")
  return true
end

function PutTheBlock()
  x, y = Game.GetPlayerPosition()
  x, y = GetBlockPos("Block0", x, y -2.5 -1)
end

i whrited and when i press M  so it close Xm and whrite :

Fatal exception occured: failed to invoke (void) PutThe BLock(): [string""]:7: attempt to call global 'GetBlockPos' (a nil value) Consult the file xmoto.log for more information about wat might has occured.

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #5 on: January 18, 2014, 04:52:22 PM »
you have to write Block0 ={} at the begining of the script...
didn't know that you don't know this... :P

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #6 on: January 18, 2014, 05:00:26 PM »
Dont work -.- .
And i have already one level created where this script work.
I dont know why dont work on this too.

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #7 on: January 18, 2014, 05:23:44 PM »
Like I said, I'll post a working script when I'm at home...
« Last Edit: January 18, 2014, 06:20:31 PM by SeRe »

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #8 on: January 18, 2014, 07:01:27 PM »
That one works:
Quote
Block0 = {}
x,y = 0,0





function OnLoad()
  Game.SetKeyHook("W", "WPutTheBlock")
  Game.SetKeyHook("A", "APutTheBlock")
  Game.SetKeyHook("S", "SPutTheBlock")
  Game.SetKeyHook("D", "DPutTheBlock")
  return true
end

function WPutTheBlock()
  x, y = Game.GetBlockPos("Block0")
  Game.SetBlockPos("Block0", x, y + 0.5)
end



function APutTheBlock()
  x, y = Game.GetBlockPos("Block0")
  Game.SetBlockPos("Block0", x - 0.5, y)
end


function SPutTheBlock()
  x, y = Game.GetBlockPos("Block0")
  Game.SetBlockPos("Block0", x, y - 0.5)
end



function DPutTheBlock()
  x, y = Game.GetBlockPos("Block0")
  Game.SetBlockPos("Block0", x + 0.5, y)
end


If that's what you want...
« Last Edit: January 18, 2014, 07:05:36 PM by SeRe »

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #9 on: January 18, 2014, 07:17:38 PM »
Dont Work too.

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #10 on: January 18, 2014, 07:23:34 PM »
Have you changed the block properties to dynamic block ?

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #11 on: January 18, 2014, 07:54:37 PM »
Have you changed the block properties to dynamic block ?

Yes, and it still dont work. I try Reinstall inkscape because i have some problems with scritps.

Wesker

  • Xmoto Player
  • *
  • Posts: 52
    • View Profile
Re: Scritp Dont Work can anyone help me?
« Reply #12 on: January 18, 2014, 08:18:52 PM »
Have you changed the block properties to dynamic block ?

Yes, and it still dont work. I try Reinstall inkscape because i have some problems with scritps.

Ok it work. And dont know you maybe how to set Game.keyhook F change block to if i press F i change to BLock 2 again F to block 3 and again F to block 1 and again and again?

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #13 on: January 18, 2014, 09:09:14 PM »
You have to use if check == 1 then, but please learn scripting before you ask me everything ;P

SeRe

  • Xmoto-Player Advanced
  • *
  • Posts: 108
  • I'm Save Urin in the game.
    • View Profile
    • http://www.saveurin.wordpress.com/
Re: Scritp Dont Work can anyone help me?
« Reply #14 on: January 18, 2014, 09:13:19 PM »
make something like that:
function ChangeBlock()
if check0 == 1 then
check0 = 0
check1 = 1
else
if check1 == 1then
check1 = 0
check0 = 1
end
end (don't know exactly how many ends are needed, so just try it)