Module API FAQ |
0 | ||
This is weird but... I know nothing about programming languages. I once learned a bit of Python. I want to make this game for my tribe, do I use the /lua popup for scripting? |
Haruhitastic « Censeur » 1376872440000
| 0 | ||
Only if you have permissions to. Also, you can't run Python in /lua. You'll have to convert it. |
Tommhawk « Citoyen » 1376892000000
| 0 | ||
Ah,I'll just be waiting till you're actually able to run Lua in tribehouse ;; |
0 | ||
Take a look at lua, It really isn't that easy that you directly can write full scripts for your tribe house when it gets released. :P http://www.phailed.me/2011/02/learn-lua-the-hard-way-1/ |
0 | ||
It was to me and I still can't run it |
Sandermr « Citoyen » 1377169020000
| 0 | ||
Will we be able to progam to kick anyone from who does meet tribe requirements and give ranks automatically so we don't have to log into Moepl's tribe bots? |
Shamousey « Consul » 1377169380000
| 0 | ||
Sandermr a dit : It'll stay dedicated to minigames, with no additional tribe-oriented functions. |
Safwanrockz « Censeur » 1377170040000
| 0 | ||
Sandermr a dit : Admis have already mentioned that you will be able to only program/code lua in your tribe houses, just like Shamo said, no additional tribe functions. |
Leafileaf « Citoyen » 1377172440000
| 0 | ||
Jordynl a dit : :/ I posted it in PasteBin. Anyway, I'm back with some code, and here's the link. http://pastebin.com/W00yxULt Some kind-hearted soul please help me see if I made any mistakes in it. EDIT: I didn't comment everything (some comments here and there though, for people wishing to understand parts that I deem more complicated), the code was pretty straight-forward. |
Shamousey « Consul » 1377172680000
| 0 | ||
There's no access to "require", "sleep", or "socket" methods. You're using "tfm.get.room.playerList[playerName].x", which can be a bit laggy, in eventKeyboard, while the event itself passes the player's x and y co-ordinates. "if bestTime then else" would probably be better off as "if not bestTime then". You need a "then" after an if or elseif statement. As it stands, your code gives the following error: a dit : [url][/url] |
Leafileaf « Citoyen » 1377173220000
| 0 | ||
Shamousey a dit : Thanks, I'll edit it. EDIT: Edited. The "then" has been rectified and I changed the if statement. P.S. What is a possible solution to remove or reduce the lag for "tfm.get.room.playerList[playerName].x"? Do I put "nil"? |
0 | ||
Stopping the script stops the script for everyone period, so it's not a good idea any way you look at it. You can use system.newTimer to create an event that occurs after a set timeframe, such as system.newTimer(function() -- tfm.exec.respawnPlayer(playerName) -- tfm.exec.chatMessage("Spawned ye matey!",playerName) -- end,5000) Note it uses ms, so 5000 is 5s |
Leafileaf « Citoyen » 1377173460000
| 0 | ||
Fxie a dit : Thanks a lot! :3 |
Shamousey « Consul » 1377174000000
| 0 | ||
Leafileaf a dit : You can't, that relies on the sync updating the player's co-ordinates which doesn't happen all that often. You could keep your own based on when a player presses a key, if you needed. |
0 | ||
Speaking of keeping your own: you should look up using variables and eventually objects if you don't know about those things. I didn't see any variables at all in your code. Althrough the keyboard function provides realtime x/y in its parameters, your code could've been local player=tfm.get.room.playerList[playerName] then just player.x and player.y for each instance where used. That's just being efficient. |
Leafileaf « Citoyen » 1377174360000
| 0 | ||
Fxie a dit : Sure, I didn't think of that. What with learning Lua and all the TFM Module API functions..... Oh, and I did use a variable to keep track of time. |
0 | ||
Oh let me lecture you on that too then "a" (might be convenient for readability by both yourself and others to use more specific names) is actually the current time (in ms), so you could have a more precise time record by simply setting timeCounter to "a," or a/1000 to convert to regular seconds. |
Leafileaf « Citoyen » 1377174900000
| 0 | ||
Fxie a dit : The event loop only executes once every 500ms so it's practically the same. I don't see any point changing that bit. |
0 | ||
Just good practice. Also helps if, by any "unusual" chance, eventLoop is horribly coded in such a way that lag does affect regularity of intervals. Y'know, incase Tig had anything to do with it. |
Leafileaf « Citoyen » 1377175680000
| 0 | ||
Fxie a dit : Ahem yea, maybe. Ok I shall implement your suggestion :P EDIT: Done. Is there anything else I can/should change in there? |