tokenzz
:thinking:
- Joined
- Feb 2, 2013
- Messages
- 779
- Solutions
- 2
- Reaction score
- 346
bit off-topic but please,LUA, is not LUA.
What you can do in LUA is directly linked to the LUA Functions made available to you in the source.
For Example, my custom server has LUA Functions not available to you. I can do things in LUA, that you cannot.
For example, I can set a creature to ignore Idle Walk so they will not walk around randomly with the function
Code:doSetIgnoreIdleWalk(cid, true)
But more specifically to the issue you are talking about.
A player using TFS 1.2 was making a monster Change Target Spell.
If he used TFS 0.X I would have given him this spell:
Code:function onCastSpell(cid, variant) local target = getCreatureTarget(cid) if isMonster(target) then doMonsterChangeTarget(target) end return true end
BUT, TFS 1.2 does not have doMonsterChangeTarget as a function.
Here is the function in 0.4.
Code:int32_t LuaInterface::luaDoMonsterChangeTarget(lua_State* L) { //doMonsterChangeTarget(cid) ScriptEnviroment* env = getEnv(); Creature* creature = env->getCreatureByUID(popNumber(L)); if(!creature) { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); return 1; } Monster* monster = creature->getMonster(); if(!monster) { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); return 1; } if(!monster->isSummon()) monster->searchTarget(TARGETSEARCH_RANDOM); lua_pushboolean(L, true); return 1; }
Instead, they linked the searchTarget function directly in TFS 1.2.
Code:int LuaScriptInterface::luaMonsterSearchTarget(lua_State* L) { // monster:searchTarget([searchType = TARGETSEARCH_DEFAULT]) Monster* monster = getUserdata<Monster>(L, 1); if (monster) { TargetSearchType_t searchType = getNumber<TargetSearchType_t>(L, 2, TARGETSEARCH_DEFAULT); pushBoolean(L, monster->searchTarget(searchType)); } else { lua_pushnil(L); } return 1; }
But as you can see, it has a different format.
Instead of using doMonsterSearchTarget(cid) They have monster:searchTarget(TARGETSEARCH_DEFAULT)
So since I do not use this format in LUA and am not familiar with it, I attempted to assist this person by giving him this script:
Which I probably should have done:Code:function onCastSpell(cid, variant) local target = getCreatureTarget(cid) if isMonster(target) then target:searchTarget() end return true end
Code:function onCastSpell(cid, variant) local target = getCreatureTarget(cid) if isMonster(target) then target:searchTarget(0) --I think this requires a number to determine the type of searching to run in the searchTarget scirpt. end return true end
Either way, the LUA is different for either one, I cannot use the same functions or even the same format unless there is a Compat function that converts the old functions to the new ones.
For example, you could make a function in TFS 1.2 that is called doMonsterChangeTarget(cid) in LUA:
Code:function doMonsterChangeTarget(cid) if isMonster(cid) then return cid:searchTarget(0) end return false end
But still, LUA is not just LUA, LUA is all about manipulating functions that you have set up in the source. And there are still differences between 0.X and 1.X, no matter what you would like to believe.
So no, the preference of coding in a specific way does not limit you when you are making your own content. It will only limit you when you are assisting people who code in a different format.
@on topic
sounds cool, good luck!