Paxton
Banned User
Well, I came up with idea to make PHP to Lua converter especially for Open Tibia.
Basically, if you want to write in PHP but get the lua results on your server, you could use this
I'm not releasing this yet, I just made first version with basic functions to make it generate simple script and well, it worked. Obviously there are still few things here and there.
What advantages does it give you.
* Well, if you don't like LUA syntax, its good for you.
* I would probably add some checks and tips so it actually helps you writing the code
* Object orientated, it would be. So you can write like rev-scripts but actually generate normal lua
and probably more
For now I wrote just the basic functions, and I found very easy script to recreate using this system.
I used this script: http://otland.net/f81/floor-tp-vips-96775/ made by AlcikOTS
Original script:
Using OTPHP
And the results generated by OTPHP:
I haven't added tabbing yet
Please discuss this, and see if something like this would be helpful. If so, I would be glad to develop this more
btw. I'm not sure if the LUA script is actually working, I've just replicated it using OTPHP, it's just to give you the idea, you know
Thanks.
Basically, if you want to write in PHP but get the lua results on your server, you could use this
I'm not releasing this yet, I just made first version with basic functions to make it generate simple script and well, it worked. Obviously there are still few things here and there.
What advantages does it give you.
* Well, if you don't like LUA syntax, its good for you.
* I would probably add some checks and tips so it actually helps you writing the code
* Object orientated, it would be. So you can write like rev-scripts but actually generate normal lua
and probably more
For now I wrote just the basic functions, and I found very easy script to recreate using this system.
I used this script: http://otland.net/f81/floor-tp-vips-96775/ made by AlcikOTS
Original script:
PHP:
--Simple script by AlcikOTS. I'am new in this things so sorry if I make any mistakes.
function onStepIn(cid, item, frompos, item2, topos)
local vip = getPlayerStorageValue(cid,11551) >= 1 --Vip Storage.
local back = {x=1000, y=1000, z=7} --Place where non vip is teleported.
local allowed = {x=1216, y=1038, z=7} --Place where VIPs are teleported.
if(vip) then
doPlayerSendTextMessage(cid, 19, "You are VIP so you are allowed to pass.")
doSendMagicEffect(getPlayerPosition(cid),2)
doTeleportThing(cid, allowed)
doSendMagicEffect(allowed,10)
else
doPlayerSendTextMessage(cid, 19, "You can't pass because you don't have Vip! You can get it in our SMS Shop.")
doTeleportThing(cid, back)
end
end
Using OTPHP
PHP:
<?php
//Load OTPHP
require 'lib/base.php';
//Main function
OTPHP::main(
//Movement event
OT_Event::onStepIn(function() {
//Lets define some local variables
LUA::local("vip", OT::getPlayerStorageValue(CID, 1155));
//We can pass arrays - I will make function specific for positions :)
LUA::local("back", array(
'x'=>1000,
'y'=>1000,
'z'=>7
));
LUA::local("allowed", array(
'x'=>1216,
'y'=>1038,
'z'=>7
));
//If statement, first argument is the statment can be multi function as well
LUA::_if(LUA::local('vip'), function() {
OTPHP::out(OT::doPlayerSendTextMessage(CID, 19, "You are VIP so you are allowed to pass."));
OTPHP::out(OT::doSendMagicEffect(OT::getPlayerPosition(CID), 2));
OTPHP::out(OT::doSendMagicEffect(LUA::local('allowed'), 2));
}, function() {
OTPHP::out(OT::doPlayerSendTextMessage(CID, 19, "You can't pass because you don't have Vip! You can get it in our SMS Shop."));
OTPHP::out(OT::doTeleportThing(CID, LUA::local('back')));
});
})
);
?>
And the results generated by OTPHP:
PHP:
function onStepIn(cid, item, frompos, item2, topos)
local vip = getPlayerStorageValue(cid, 1155)
local back = {x = 1000, y = 1000, z = 7}
local allowed = {x = 1216, y = 1038, z = 7}
if(vip) then
doPlayerSendTextMessage(cid, 19, "You are VIP so you are allowed to pass.")
doSendMagicEffect(getPlayerPosition(cid), 2)
doSendMagicEffect(allowed, 2)
else
doPlayerSendTextMessage(cid, 19, "You can't pass because you don't have Vip! You can get it in our SMS Shop.")
doTeleportThing(cid, back)
end
end
I haven't added tabbing yet
Please discuss this, and see if something like this would be helpful. If so, I would be glad to develop this more
btw. I'm not sure if the LUA script is actually working, I've just replicated it using OTPHP, it's just to give you the idea, you know
Thanks.
Last edited: