Steam'i Yükleyin
giriş
|
dil
简体中文 (Basitleştirilmiş Çince)
繁體中文 (Geleneksel Çince)
日本語 (Japonca)
한국어 (Korece)
ไทย (Tayca)
Български (Bulgarca)
Čeština (Çekçe)
Dansk (Danca)
Deutsch (Almanca)
English (İngilizce)
Español - España (İspanyolca - İspanya)
Español - Latinoamérica (İspanyolca - Latin Amerika)
Ελληνικά (Yunanca)
Français (Fransızca)
Italiano (İtalyanca)
Bahasa Indonesia (Endonezce)
Magyar (Macarca)
Nederlands (Hollandaca)
Norsk (Norveççe)
Polski (Lehçe)
Português (Portekizce - Portekiz)
Português - Brasil (Portekizce - Brezilya)
Română (Rumence)
Русский (Rusça)
Suomi (Fince)
Svenska (İsveççe)
Tiếng Việt (Vietnamca)
Українська (Ukraynaca)
Bir çeviri sorunu bildirin
Lua "self" doesn't work like "this" in any other class languages, it just works as a pre-made pointer in a special-call function to a table that it belongs to, basically:
MyClass:SomeFunction(number)
end
is similar to this:
MyClass.SomeFunction(self,number)
end
If you will do something like that
local t1 = {}
local t2 = t1
It will not create a new table; you have to manually copy table contents into a new table,lua tables are stored as pointers and not new instances. To copy, you can do something like that:
for i,v in t1 do
t2 = v
end
I don't remember if SW has a table.copy(); if it does, then use it instead of for loops
However, I find it a bit strange, that "print" is a recocnized command/function within SW's LUA editor, but throws out a complete missleading error.(interpreting a function as a non-initialized variable).
Anyway...I used 30 memory-registers and plenty of function-blocks to emulate a 10-byte, 3 bits wide data register to use this as a LUA-table replacement.
The good thing is, all this mem-content-datasets are surviving a save/reload-game.
This, I believe is not possible in SW's LUA.
However...many thanks again.
Example with white text saying Hello:
function onDraw()
screen.setColor(255,255,255)
screen.drawText(0, 0, "Hello")
end
The "0, 0," are x, y coordinates to determine where to place the text on the screen. 0,0 means the text will be in the upper left corner. Hope this helped!
I just want to write "hello world" on the attached screen using "print".
But the lua-interpreter allways handles "print" as an undefined global variable (error 38).
This happens when: 1, I try to access the function...or 2. when using no function...just print("hello world")
Just traingf to learn teh basics because all I want is:
.....to store 3 values per variable/dataset...so tables comes to mind.
(X-xoordinate,y-coordinate, action to perform)
next data-set..etc
I guess, I limit to 10 datasets and use memory registers then (so 3*10 memory registers).
This lua-stuff is too strange for me.
function onDraw()
sc = screen.setColor
sc(0,0,0)
end
This example can REALLY help optimize the code; this can be applied to any function that the Stormworks Lua API provides. If you are using some function more than once, then you definitely need to make a pointer for that function.